2 * ITfInputProcessorProfiles implementation
4 * Copyright 2009 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 static const WCHAR szwLngp[] = {'L','a','n','g','u','a','g','e','P','r','o','f','i','l','e',0};
44 static const WCHAR szwEnabled[] = {'E','n','a','b','l','e','d',0};
45 static const WCHAR szwTipfmt[] = {'%','s','\\','%','s',0};
46 static const WCHAR szwFullLangfmt[] = {'%','s','\\','%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
48 typedef struct tagInputProcessorProfiles {
49 const ITfInputProcessorProfilesVtbl *InputProcessorProfilesVtbl;
52 LANGID currentLanguage;
53 } InputProcessorProfiles;
55 static void InputProcessorProfiles_Destructor(InputProcessorProfiles *This)
57 TRACE("destroying %p\n", This);
58 HeapFree(GetProcessHeap(),0,This);
61 static void add_userkey( REFCLSID rclsid, LANGID langid,
68 DWORD disposition = 0;
73 StringFromGUID2(rclsid, buf, 39);
74 StringFromGUID2(guidProfile, buf2, 39);
75 sprintfW(fullkey,szwFullLangfmt,szwSystemTIPKey,buf,szwLngp,langid,buf2);
77 res = RegCreateKeyExW(HKEY_CURRENT_USER,fullkey, 0, NULL, 0,
78 KEY_READ | KEY_WRITE, NULL, &key, &disposition);
80 if (!res && disposition == REG_CREATED_NEW_KEY)
83 RegSetValueExW(key, szwEnabled, 0, REG_DWORD, (LPBYTE)&zero, sizeof(DWORD));
90 static HRESULT WINAPI InputProcessorProfiles_QueryInterface(ITfInputProcessorProfiles *iface, REFIID iid, LPVOID *ppvOut)
92 InputProcessorProfiles *This = (InputProcessorProfiles *)iface;
95 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfInputProcessorProfiles))
102 IUnknown_AddRef(iface);
106 WARN("unsupported interface: %s\n", debugstr_guid(iid));
107 return E_NOINTERFACE;
110 static ULONG WINAPI InputProcessorProfiles_AddRef(ITfInputProcessorProfiles *iface)
112 InputProcessorProfiles *This = (InputProcessorProfiles *)iface;
113 return InterlockedIncrement(&This->refCount);
116 static ULONG WINAPI InputProcessorProfiles_Release(ITfInputProcessorProfiles *iface)
118 InputProcessorProfiles *This = (InputProcessorProfiles *)iface;
121 ret = InterlockedDecrement(&This->refCount);
123 InputProcessorProfiles_Destructor(This);
127 /*****************************************************
128 * ITfInputProcessorProfiles functions
129 *****************************************************/
130 static HRESULT WINAPI InputProcessorProfiles_Register(
131 ITfInputProcessorProfiles *iface, REFCLSID rclsid)
133 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
138 TRACE("(%p) %s\n",This,debugstr_guid(rclsid));
140 StringFromGUID2(rclsid, buf, 39);
141 sprintfW(fullkey,szwTipfmt,szwSystemTIPKey,buf);
143 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,fullkey, 0, NULL, 0,
144 KEY_READ | KEY_WRITE, NULL, &tipkey, NULL) != ERROR_SUCCESS)
152 static HRESULT WINAPI InputProcessorProfiles_Unregister(
153 ITfInputProcessorProfiles *iface, REFCLSID rclsid)
155 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
156 FIXME("STUB:(%p)\n",This);
160 static HRESULT WINAPI InputProcessorProfiles_AddLanguageProfile(
161 ITfInputProcessorProfiles *iface, REFCLSID rclsid,
162 LANGID langid, REFGUID guidProfile, const WCHAR *pchDesc,
163 ULONG cchDesc, const WCHAR *pchIconFile, ULONG cchFile,
170 DWORD disposition = 0;
172 static const WCHAR fmt2[] = {'%','s','\\','0','x','%','0','8','x','\\','%','s',0};
173 static const WCHAR desc[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
174 static const WCHAR icnf[] = {'I','c','o','n','F','i','l','e',0};
175 static const WCHAR icni[] = {'I','c','o','n','I','n','d','e','x',0};
177 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
179 TRACE("(%p) %s %x %s %s %s %i\n",This,debugstr_guid(rclsid), langid,
180 debugstr_guid(guidProfile), debugstr_wn(pchDesc,cchDesc),
181 debugstr_wn(pchIconFile,cchFile),uIconIndex);
183 StringFromGUID2(rclsid, buf, 39);
184 sprintfW(fullkey,szwTipfmt,szwSystemTIPKey,buf);
186 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,fullkey, 0, KEY_READ | KEY_WRITE,
187 &tipkey ) != ERROR_SUCCESS)
190 StringFromGUID2(guidProfile, buf, 39);
191 sprintfW(fullkey,fmt2,szwLngp,langid,buf);
193 res = RegCreateKeyExW(tipkey,fullkey, 0, NULL, 0, KEY_READ | KEY_WRITE,
194 NULL, &fmtkey, &disposition);
199 RegSetValueExW(fmtkey, desc, 0, REG_SZ, (LPBYTE)pchDesc, cchDesc * sizeof(WCHAR));
200 RegSetValueExW(fmtkey, icnf, 0, REG_SZ, (LPBYTE)pchIconFile, cchFile * sizeof(WCHAR));
201 RegSetValueExW(fmtkey, icni, 0, REG_DWORD, (LPBYTE)&uIconIndex, sizeof(DWORD));
202 if (disposition == REG_CREATED_NEW_KEY)
203 RegSetValueExW(fmtkey, szwEnabled, 0, REG_DWORD, (LPBYTE)&zero, sizeof(DWORD));
206 add_userkey(rclsid, langid, guidProfile);
216 static HRESULT WINAPI InputProcessorProfiles_RemoveLanguageProfile(
217 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
220 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
221 FIXME("STUB:(%p)\n",This);
225 static HRESULT WINAPI InputProcessorProfiles_EnumInputProcessorInfo(
226 ITfInputProcessorProfiles *iface, IEnumGUID **ppEnum)
228 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
229 FIXME("STUB:(%p)\n",This);
233 static HRESULT WINAPI InputProcessorProfiles_GetDefaultLanguageProfile(
234 ITfInputProcessorProfiles *iface, LANGID langid, REFGUID catid,
235 CLSID *pclsid, GUID *pguidProfile)
237 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
238 FIXME("STUB:(%p)\n",This);
242 static HRESULT WINAPI InputProcessorProfiles_SetDefaultLanguageProfile(
243 ITfInputProcessorProfiles *iface, LANGID langid, REFCLSID rclsid,
244 REFGUID guidProfiles)
246 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
247 FIXME("STUB:(%p)\n",This);
251 static HRESULT WINAPI InputProcessorProfiles_ActivateLanguageProfile(
252 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
253 REFGUID guidProfiles)
255 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
256 FIXME("STUB:(%p)\n",This);
260 static HRESULT WINAPI InputProcessorProfiles_GetActiveLanguageProfile(
261 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID *plangid,
264 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
265 FIXME("STUB:(%p)\n",This);
269 static HRESULT WINAPI InputProcessorProfiles_GetLanguageProfileDescription(
270 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
271 REFGUID guidProfile, BSTR *pbstrProfile)
273 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
274 FIXME("STUB:(%p)\n",This);
278 static HRESULT WINAPI InputProcessorProfiles_GetCurrentLanguage(
279 ITfInputProcessorProfiles *iface, LANGID *plangid)
281 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
282 TRACE("(%p) 0x%x\n",This,This->currentLanguage);
287 *plangid = This->currentLanguage;
292 static HRESULT WINAPI InputProcessorProfiles_ChangeCurrentLanguage(
293 ITfInputProcessorProfiles *iface, LANGID langid)
295 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
296 FIXME("STUB:(%p)\n",This);
300 static HRESULT WINAPI InputProcessorProfiles_GetLanguageList(
301 ITfInputProcessorProfiles *iface, LANGID **ppLangId, ULONG *pulCount)
303 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
304 FIXME("STUB:(%p)\n",This);
308 static HRESULT WINAPI InputProcessorProfiles_EnumLanguageProfiles(
309 ITfInputProcessorProfiles *iface, LANGID langid,
310 IEnumTfLanguageProfiles **ppEnum)
312 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
313 FIXME("STUB:(%p)\n",This);
317 static HRESULT WINAPI InputProcessorProfiles_EnableLanguageProfile(
318 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
319 REFGUID guidProfile, BOOL fEnable)
321 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
322 FIXME("STUB:(%p)\n",This);
326 static HRESULT WINAPI InputProcessorProfiles_IsEnabledLanguageProfile(
327 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
328 REFGUID guidProfile, BOOL *pfEnable)
330 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
331 FIXME("STUB:(%p)\n",This);
335 static HRESULT WINAPI InputProcessorProfiles_EnableLanguageProfileByDefault(
336 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
337 REFGUID guidProfile, BOOL fEnable)
339 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
340 FIXME("STUB:(%p)\n",This);
344 static HRESULT WINAPI InputProcessorProfiles_SubstituteKeyboardLayout(
345 ITfInputProcessorProfiles *iface, REFCLSID rclsid, LANGID langid,
346 REFGUID guidProfile, HKL hKL)
348 InputProcessorProfiles *This = (InputProcessorProfiles*)iface;
349 FIXME("STUB:(%p)\n",This);
354 static const ITfInputProcessorProfilesVtbl InputProcessorProfiles_InputProcessorProfilesVtbl =
356 InputProcessorProfiles_QueryInterface,
357 InputProcessorProfiles_AddRef,
358 InputProcessorProfiles_Release,
360 InputProcessorProfiles_Register,
361 InputProcessorProfiles_Unregister,
362 InputProcessorProfiles_AddLanguageProfile,
363 InputProcessorProfiles_RemoveLanguageProfile,
364 InputProcessorProfiles_EnumInputProcessorInfo,
365 InputProcessorProfiles_GetDefaultLanguageProfile,
366 InputProcessorProfiles_SetDefaultLanguageProfile,
367 InputProcessorProfiles_ActivateLanguageProfile,
368 InputProcessorProfiles_GetActiveLanguageProfile,
369 InputProcessorProfiles_GetLanguageProfileDescription,
370 InputProcessorProfiles_GetCurrentLanguage,
371 InputProcessorProfiles_ChangeCurrentLanguage,
372 InputProcessorProfiles_GetLanguageList,
373 InputProcessorProfiles_EnumLanguageProfiles,
374 InputProcessorProfiles_EnableLanguageProfile,
375 InputProcessorProfiles_IsEnabledLanguageProfile,
376 InputProcessorProfiles_EnableLanguageProfileByDefault,
377 InputProcessorProfiles_SubstituteKeyboardLayout
380 HRESULT InputProcessorProfiles_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
382 InputProcessorProfiles *This;
384 return CLASS_E_NOAGGREGATION;
386 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputProcessorProfiles));
388 return E_OUTOFMEMORY;
390 This->InputProcessorProfilesVtbl= &InputProcessorProfiles_InputProcessorProfilesVtbl;
392 This->currentLanguage = GetUserDefaultLCID();
394 TRACE("returning %p\n", This);
395 *ppOut = (IUnknown *)This;