msctf: Implement InputProcessorProfiles::GetCurrentLanguage.
[wine] / dlls / msctf / inputprocessor.c
1 /*
2  *  ITfInputProcessorProfiles implementation
3  *
4  *  Copyright 2009 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 tagInputProcessorProfiles {
44     const ITfInputProcessorProfilesVtbl *InputProcessorProfilesVtbl;
45     LONG refCount;
46
47     LANGID  currentLanguage;
48 } InputProcessorProfiles;
49
50 static void InputProcessorProfiles_Destructor(InputProcessorProfiles *This)
51 {
52     TRACE("destroying %p\n", This);
53     HeapFree(GetProcessHeap(),0,This);
54 }
55
56 static HRESULT WINAPI InputProcessorProfiles_QueryInterface(ITfInputProcessorProfiles *iface, REFIID iid, LPVOID *ppvOut)
57 {
58     InputProcessorProfiles *This = (InputProcessorProfiles *)iface;
59     *ppvOut = NULL;
60
61     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfInputProcessorProfiles))
62     {
63         *ppvOut = This;
64     }
65
66     if (*ppvOut)
67     {
68         IUnknown_AddRef(iface);
69         return S_OK;
70     }
71
72     WARN("unsupported interface: %s\n", debugstr_guid(iid));
73     return E_NOINTERFACE;
74 }
75
76 static ULONG WINAPI InputProcessorProfiles_AddRef(ITfInputProcessorProfiles *iface)
77 {
78     InputProcessorProfiles *This = (InputProcessorProfiles *)iface;
79     return InterlockedIncrement(&This->refCount);
80 }
81
82 static ULONG WINAPI InputProcessorProfiles_Release(ITfInputProcessorProfiles *iface)
83 {
84     InputProcessorProfiles *This = (InputProcessorProfiles *)iface;
85     ULONG ret;
86
87     ret = InterlockedDecrement(&This->refCount);
88     if (ret == 0)
89         InputProcessorProfiles_Destructor(This);
90     return ret;
91 }
92
93 /*****************************************************
94  * ITfInputProcessorProfiles functions
95  *****************************************************/
96 static HRESULT WINAPI InputProcessorProfiles_Register(
97         ITfInputProcessorProfiles *iface, REFCLSID rclsid)
98 {
99     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
100     FIXME("STUB:(%p)\n",This);
101     return E_NOTIMPL;
102 }
103
104 static HRESULT WINAPI InputProcessorProfiles_Unregister(
105         ITfInputProcessorProfiles *iface, REFCLSID rclsid)
106 {
107     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
108     FIXME("STUB:(%p)\n",This);
109     return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI InputProcessorProfiles_AddLanguageProfile(
113         ITfInputProcessorProfiles *iface, REFCLSID rclsid,
114         LANGID langid, REFGUID guidProfile, const WCHAR *pchDesc,
115         ULONG cchDesc, const WCHAR *pchIconFile, ULONG cchFile,
116         ULONG uIconIndex)
117 {
118     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
119     FIXME("STUB:(%p)\n",This);
120     return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI InputProcessorProfiles_RemoveLanguageProfile(
124         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
125         REFGUID guidProfile)
126 {
127     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
128     FIXME("STUB:(%p)\n",This);
129     return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI InputProcessorProfiles_EnumInputProcessorInfo(
133         ITfInputProcessorProfiles *iface, IEnumGUID **ppEnum)
134 {
135     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
136     FIXME("STUB:(%p)\n",This);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI InputProcessorProfiles_GetDefaultLanguageProfile(
141         ITfInputProcessorProfiles *iface, LANGID langid, REFGUID catid,
142         CLSID *pclsid, GUID *pguidProfile)
143 {
144     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
145     FIXME("STUB:(%p)\n",This);
146     return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI InputProcessorProfiles_SetDefaultLanguageProfile(
150         ITfInputProcessorProfiles *iface, LANGID langid, REFCLSID rclsid,
151         REFGUID guidProfiles)
152 {
153     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
154     FIXME("STUB:(%p)\n",This);
155     return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI InputProcessorProfiles_ActivateLanguageProfile(
159         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
160         REFGUID guidProfiles)
161 {
162     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
163     FIXME("STUB:(%p)\n",This);
164     return E_NOTIMPL;
165 }
166
167 static HRESULT WINAPI InputProcessorProfiles_GetActiveLanguageProfile(
168         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID *plangid,
169         GUID *pguidProfile)
170 {
171     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
172     FIXME("STUB:(%p)\n",This);
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI InputProcessorProfiles_GetLanguageProfileDescription(
177         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
178         REFGUID guidProfile, BSTR *pbstrProfile)
179 {
180     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
181     FIXME("STUB:(%p)\n",This);
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI InputProcessorProfiles_GetCurrentLanguage(
186         ITfInputProcessorProfiles *iface, LANGID *plangid)
187 {
188     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
189     TRACE("(%p) 0x%x\n",This,This->currentLanguage);
190
191     if (!plangid)
192         return E_INVALIDARG;
193
194     *plangid = This->currentLanguage;
195
196     return S_OK;
197 }
198
199 static HRESULT WINAPI InputProcessorProfiles_ChangeCurrentLanguage(
200         ITfInputProcessorProfiles *iface, LANGID langid)
201 {
202     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
203     FIXME("STUB:(%p)\n",This);
204     return E_NOTIMPL;
205 }
206
207 static HRESULT WINAPI InputProcessorProfiles_GetLanguageList(
208         ITfInputProcessorProfiles *iface, LANGID **ppLangId, ULONG *pulCount)
209 {
210     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
211     FIXME("STUB:(%p)\n",This);
212     return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI InputProcessorProfiles_EnumLanguageProfiles(
216         ITfInputProcessorProfiles *iface, LANGID langid,
217         IEnumTfLanguageProfiles **ppEnum)
218 {
219     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
220     FIXME("STUB:(%p)\n",This);
221     return E_NOTIMPL;
222 }
223
224 static HRESULT WINAPI InputProcessorProfiles_EnableLanguageProfile(
225         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
226         REFGUID guidProfile, BOOL fEnable)
227 {
228     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
229     FIXME("STUB:(%p)\n",This);
230     return E_NOTIMPL;
231 }
232
233 static HRESULT WINAPI InputProcessorProfiles_IsEnabledLanguageProfile(
234         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
235         REFGUID guidProfile, BOOL *pfEnable)
236 {
237     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
238     FIXME("STUB:(%p)\n",This);
239     return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI InputProcessorProfiles_EnableLanguageProfileByDefault(
243         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
244         REFGUID guidProfile, BOOL fEnable)
245 {
246     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
247     FIXME("STUB:(%p)\n",This);
248     return E_NOTIMPL;
249 }
250
251 static HRESULT WINAPI InputProcessorProfiles_SubstituteKeyboardLayout(
252         ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
253         REFGUID guidProfile, HKL hKL)
254 {
255     InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
256     FIXME("STUB:(%p)\n",This);
257     return E_NOTIMPL;
258 }
259
260
261 static const ITfInputProcessorProfilesVtbl InputProcessorProfiles_InputProcessorProfilesVtbl =
262 {
263     InputProcessorProfiles_QueryInterface,
264     InputProcessorProfiles_AddRef,
265     InputProcessorProfiles_Release,
266
267     InputProcessorProfiles_Register,
268     InputProcessorProfiles_Unregister,
269     InputProcessorProfiles_AddLanguageProfile,
270     InputProcessorProfiles_RemoveLanguageProfile,
271     InputProcessorProfiles_EnumInputProcessorInfo,
272     InputProcessorProfiles_GetDefaultLanguageProfile,
273     InputProcessorProfiles_SetDefaultLanguageProfile,
274     InputProcessorProfiles_ActivateLanguageProfile,
275     InputProcessorProfiles_GetActiveLanguageProfile,
276     InputProcessorProfiles_GetLanguageProfileDescription,
277     InputProcessorProfiles_GetCurrentLanguage,
278     InputProcessorProfiles_ChangeCurrentLanguage,
279     InputProcessorProfiles_GetLanguageList,
280     InputProcessorProfiles_EnumLanguageProfiles,
281     InputProcessorProfiles_EnableLanguageProfile,
282     InputProcessorProfiles_IsEnabledLanguageProfile,
283     InputProcessorProfiles_EnableLanguageProfileByDefault,
284     InputProcessorProfiles_SubstituteKeyboardLayout
285 };
286
287 HRESULT InputProcessorProfiles_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
288 {
289     InputProcessorProfiles *This;
290     if (pUnkOuter)
291         return CLASS_E_NOAGGREGATION;
292
293     This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputProcessorProfiles));
294     if (This == NULL)
295         return E_OUTOFMEMORY;
296
297     This->InputProcessorProfilesVtbl= &InputProcessorProfiles_InputProcessorProfilesVtbl;
298     This->refCount = 1;
299     This->currentLanguage = GetUserDefaultLCID();
300
301     TRACE("returning %p\n", This);
302     *ppOut = (IUnknown *)This;
303     return S_OK;
304 }