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
21 #include "msctf_internal.h"
23 static const WCHAR szwLngp
[] = {'L','a','n','g','u','a','g','e','P','r','o','f','i','l','e',0};
24 static const WCHAR szwEnable
[] = {'E','n','a','b','l','e',0};
25 static const WCHAR szwTipfmt
[] = {'%','s','\\','%','s',0};
26 static const WCHAR szwFullLangfmt
[] = {'%','s','\\','%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
28 static const WCHAR szwAssemblies
[] = {'A','s','s','e','m','b','l','i','e','s',0};
29 static const WCHAR szwDefault
[] = {'D','e','f','a','u','l','t',0};
30 static const WCHAR szwProfile
[] = {'P','r','o','f','i','l','e',0};
31 static const WCHAR szwDefaultFmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
33 typedef struct tagInputProcessorProfilesSink
{
36 /* InputProcessorProfile Sinks */
38 ITfLanguageProfileNotifySink
*pITfLanguageProfileNotifySink
;
40 } InputProcessorProfilesSink
;
42 typedef struct tagInputProcessorProfiles
{
43 ITfInputProcessorProfiles ITfInputProcessorProfiles_iface
;
44 ITfSource ITfSource_iface
;
45 ITfInputProcessorProfileMgr ITfInputProcessorProfileMgr_iface
;
46 /* const ITfInputProcessorProfilesExVtbl *InputProcessorProfilesExVtbl; */
47 /* const ITfInputProcessorProfileSubstituteLayoutVtbl *InputProcessorProfileSubstituteLayoutVtbl; */
50 LANGID currentLanguage
;
52 struct list LanguageProfileNotifySink
;
53 } InputProcessorProfiles
;
55 typedef struct tagProfilesEnumGuid
{
56 IEnumGUID IEnumGUID_iface
;
63 typedef struct tagEnumTfLanguageProfiles
{
64 IEnumTfLanguageProfiles IEnumTfLanguageProfiles_iface
;
69 WCHAR szwCurrentClsid
[39];
75 ITfCategoryMgr
*catmgr
;
76 } EnumTfLanguageProfiles
;
79 IEnumTfInputProcessorProfiles IEnumTfInputProcessorProfiles_iface
;
81 } EnumTfInputProcessorProfiles
;
83 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
);
84 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, IEnumTfLanguageProfiles
**ppOut
);
86 static inline EnumTfInputProcessorProfiles
*impl_from_IEnumTfInputProcessorProfiles(IEnumTfInputProcessorProfiles
*iface
)
88 return CONTAINING_RECORD(iface
, EnumTfInputProcessorProfiles
, IEnumTfInputProcessorProfiles_iface
);
91 static HRESULT WINAPI
EnumTfInputProcessorProfiles_QueryInterface(IEnumTfInputProcessorProfiles
*iface
,
92 REFIID riid
, void **ppv
)
94 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
96 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
97 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
98 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
99 }else if(IsEqualGUID(riid
, &IID_IEnumTfInputProcessorProfiles
)) {
100 TRACE("(%p)->(IID_IEnumTfInputProcessorProfiles %p)\n", This
, ppv
);
101 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
104 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
105 return E_NOINTERFACE
;
108 IUnknown_AddRef((IUnknown
*)*ppv
);
112 static ULONG WINAPI
EnumTfInputProcessorProfiles_AddRef(IEnumTfInputProcessorProfiles
*iface
)
114 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
115 LONG ref
= InterlockedIncrement(&This
->ref
);
117 TRACE("(%p) ref=%d\n", This
, ref
);
122 static ULONG WINAPI
EnumTfInputProcessorProfiles_Release(IEnumTfInputProcessorProfiles
*iface
)
124 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
125 LONG ref
= InterlockedDecrement(&This
->ref
);
127 TRACE("(%p) ref=%d\n", This
, ref
);
130 HeapFree(GetProcessHeap(), 0, This
);
135 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Clone(IEnumTfInputProcessorProfiles
*iface
,
136 IEnumTfInputProcessorProfiles
**ret
)
138 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
139 FIXME("(%p)->(%p)\n", This
, ret
);
143 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Next(IEnumTfInputProcessorProfiles
*iface
, ULONG count
,
144 TF_INPUTPROCESSORPROFILE
*profile
, ULONG
*fetch
)
146 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
148 FIXME("(%p)->(%u %p %p)\n", This
, count
, profile
, fetch
);
155 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Reset(IEnumTfInputProcessorProfiles
*iface
)
157 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
158 FIXME("(%p)\n", This
);
162 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Skip(IEnumTfInputProcessorProfiles
*iface
, ULONG count
)
164 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
165 FIXME("(%p)->(%u)\n", This
, count
);
169 static const IEnumTfInputProcessorProfilesVtbl EnumTfInputProcessorProfilesVtbl
= {
170 EnumTfInputProcessorProfiles_QueryInterface
,
171 EnumTfInputProcessorProfiles_AddRef
,
172 EnumTfInputProcessorProfiles_Release
,
173 EnumTfInputProcessorProfiles_Clone
,
174 EnumTfInputProcessorProfiles_Next
,
175 EnumTfInputProcessorProfiles_Reset
,
176 EnumTfInputProcessorProfiles_Skip
179 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfiles(ITfInputProcessorProfiles
*iface
)
181 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfiles_iface
);
184 static inline InputProcessorProfiles
*impl_from_ITfSource(ITfSource
*iface
)
186 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfSource_iface
);
189 static inline ProfilesEnumGuid
*impl_from_IEnumGUID(IEnumGUID
*iface
)
191 return CONTAINING_RECORD(iface
, ProfilesEnumGuid
, IEnumGUID_iface
);
194 static inline EnumTfLanguageProfiles
*impl_from_IEnumTfLanguageProfiles(IEnumTfLanguageProfiles
*iface
)
196 return CONTAINING_RECORD(iface
, EnumTfLanguageProfiles
, IEnumTfLanguageProfiles_iface
);
199 static void free_sink(InputProcessorProfilesSink
*sink
)
201 IUnknown_Release(sink
->interfaces
.pIUnknown
);
202 HeapFree(GetProcessHeap(),0,sink
);
205 static void InputProcessorProfiles_Destructor(InputProcessorProfiles
*This
)
207 struct list
*cursor
, *cursor2
;
208 TRACE("destroying %p\n", This
);
211 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &This
->LanguageProfileNotifySink
)
213 InputProcessorProfilesSink
* sink
= LIST_ENTRY(cursor
,InputProcessorProfilesSink
,entry
);
218 HeapFree(GetProcessHeap(),0,This
);
221 static void add_userkey( REFCLSID rclsid
, LANGID langid
,
228 DWORD disposition
= 0;
233 StringFromGUID2(rclsid
, buf
, 39);
234 StringFromGUID2(guidProfile
, buf2
, 39);
235 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
237 res
= RegCreateKeyExW(HKEY_CURRENT_USER
,fullkey
, 0, NULL
, 0,
238 KEY_READ
| KEY_WRITE
, NULL
, &key
, &disposition
);
240 if (!res
&& disposition
== REG_CREATED_NEW_KEY
)
243 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
250 static HRESULT WINAPI
InputProcessorProfiles_QueryInterface(ITfInputProcessorProfiles
*iface
, REFIID iid
, void **ppv
)
252 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
254 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_ITfInputProcessorProfiles
))
256 *ppv
= &This
->ITfInputProcessorProfiles_iface
;
258 else if (IsEqualIID(iid
, &IID_ITfInputProcessorProfileMgr
))
260 *ppv
= &This
->ITfInputProcessorProfileMgr_iface
;
262 else if (IsEqualIID(iid
, &IID_ITfSource
))
264 *ppv
= &This
->ITfSource_iface
;
269 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
270 return E_NOINTERFACE
;
273 ITfInputProcessorProfiles_AddRef(iface
);
277 static ULONG WINAPI
InputProcessorProfiles_AddRef(ITfInputProcessorProfiles
*iface
)
279 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
280 return InterlockedIncrement(&This
->refCount
);
283 static ULONG WINAPI
InputProcessorProfiles_Release(ITfInputProcessorProfiles
*iface
)
285 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
288 ret
= InterlockedDecrement(&This
->refCount
);
290 InputProcessorProfiles_Destructor(This
);
294 /*****************************************************
295 * ITfInputProcessorProfiles functions
296 *****************************************************/
297 static HRESULT WINAPI
InputProcessorProfiles_Register(
298 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
300 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
305 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
307 StringFromGUID2(rclsid
, buf
, 39);
308 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
310 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, NULL
, 0,
311 KEY_READ
| KEY_WRITE
, NULL
, &tipkey
, NULL
) != ERROR_SUCCESS
)
319 static HRESULT WINAPI
InputProcessorProfiles_Unregister(
320 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
322 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
326 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
328 StringFromGUID2(rclsid
, buf
, 39);
329 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
331 SHDeleteKeyW(HKEY_LOCAL_MACHINE
, fullkey
);
332 SHDeleteKeyW(HKEY_CURRENT_USER
, fullkey
);
337 static HRESULT WINAPI
InputProcessorProfiles_AddLanguageProfile(
338 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
,
339 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
,
340 ULONG cchDesc
, const WCHAR
*pchIconFile
, ULONG cchFile
,
343 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
348 DWORD disposition
= 0;
350 static const WCHAR fmt2
[] = {'%','s','\\','0','x','%','0','8','x','\\','%','s',0};
351 static const WCHAR desc
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
352 static const WCHAR icnf
[] = {'I','c','o','n','F','i','l','e',0};
353 static const WCHAR icni
[] = {'I','c','o','n','I','n','d','e','x',0};
355 TRACE("(%p) %s %x %s %s %s %i\n",This
,debugstr_guid(rclsid
), langid
,
356 debugstr_guid(guidProfile
), debugstr_wn(pchDesc
,cchDesc
),
357 debugstr_wn(pchIconFile
,cchFile
),uIconIndex
);
359 StringFromGUID2(rclsid
, buf
, 39);
360 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
362 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, KEY_READ
| KEY_WRITE
,
363 &tipkey
) != ERROR_SUCCESS
)
366 StringFromGUID2(guidProfile
, buf
, 39);
367 sprintfW(fullkey
,fmt2
,szwLngp
,langid
,buf
);
369 res
= RegCreateKeyExW(tipkey
,fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
370 NULL
, &fmtkey
, &disposition
);
375 RegSetValueExW(fmtkey
, desc
, 0, REG_SZ
, (const BYTE
*)pchDesc
, cchDesc
* sizeof(WCHAR
));
376 RegSetValueExW(fmtkey
, icnf
, 0, REG_SZ
, (const BYTE
*)pchIconFile
, cchFile
* sizeof(WCHAR
));
377 RegSetValueExW(fmtkey
, icni
, 0, REG_DWORD
, (LPBYTE
)&uIconIndex
, sizeof(DWORD
));
378 if (disposition
== REG_CREATED_NEW_KEY
)
379 RegSetValueExW(fmtkey
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
382 add_userkey(rclsid
, langid
, guidProfile
);
392 static HRESULT WINAPI
InputProcessorProfiles_RemoveLanguageProfile(
393 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
396 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
397 FIXME("STUB:(%p)\n",This
);
401 static HRESULT WINAPI
InputProcessorProfiles_EnumInputProcessorInfo(
402 ITfInputProcessorProfiles
*iface
, IEnumGUID
**ppEnum
)
404 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
405 TRACE("(%p) %p\n",This
,ppEnum
);
406 return ProfilesEnumGuid_Constructor(ppEnum
);
409 static HRESULT WINAPI
InputProcessorProfiles_GetDefaultLanguageProfile(
410 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFGUID catid
,
411 CLSID
*pclsid
, GUID
*pguidProfile
)
413 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
420 TRACE("%p) %x %s %p %p\n",This
, langid
, debugstr_guid(catid
),pclsid
,pguidProfile
);
422 if (!catid
|| !pclsid
|| !pguidProfile
)
425 StringFromGUID2(catid
, buf
, 39);
426 sprintfW(fullkey
, szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
428 if (RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
,
429 &hkey
) != ERROR_SUCCESS
)
433 res
= RegQueryValueExW(hkey
, szwDefault
, 0, NULL
, (LPBYTE
)buf
, &count
);
434 if (res
!= ERROR_SUCCESS
)
439 CLSIDFromString(buf
,pclsid
);
441 res
= RegQueryValueExW(hkey
, szwProfile
, 0, NULL
, (LPBYTE
)buf
, &count
);
442 if (res
== ERROR_SUCCESS
)
443 CLSIDFromString(buf
,pguidProfile
);
450 static HRESULT WINAPI
InputProcessorProfiles_SetDefaultLanguageProfile(
451 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFCLSID rclsid
,
452 REFGUID guidProfiles
)
454 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
460 ITfCategoryMgr
*catmgr
;
461 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
462 &GUID_TFCAT_TIP_SPEECH
,
463 &GUID_TFCAT_TIP_HANDWRITING
};
465 TRACE("%p) %x %s %s\n",This
, langid
, debugstr_guid(rclsid
),debugstr_guid(guidProfiles
));
467 if (!rclsid
|| !guidProfiles
)
470 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&catmgr
);
475 if (ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
476 &catid
, tipcats
, 3) != S_OK
)
477 hr
= ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
479 ITfCategoryMgr_Release(catmgr
);
484 StringFromGUID2(&catid
, buf
, 39);
485 sprintfW(fullkey
, szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
487 if (RegCreateKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
488 NULL
, &hkey
, NULL
) != ERROR_SUCCESS
)
491 StringFromGUID2(rclsid
, buf
, 39);
492 RegSetValueExW(hkey
, szwDefault
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
493 StringFromGUID2(guidProfiles
, buf
, 39);
494 RegSetValueExW(hkey
, szwProfile
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
500 static HRESULT WINAPI
InputProcessorProfiles_ActivateLanguageProfile(
501 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
502 REFGUID guidProfiles
)
504 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
507 TF_LANGUAGEPROFILE LanguageProfile
;
509 TRACE("(%p) %s %x %s\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfiles
));
511 if (langid
!= This
->currentLanguage
) return E_INVALIDARG
;
513 if (get_active_textservice(rclsid
,NULL
))
515 TRACE("Already Active\n");
519 hr
= ITfInputProcessorProfiles_IsEnabledLanguageProfile(iface
, rclsid
,
520 langid
, guidProfiles
, &enabled
);
521 if (FAILED(hr
) || !enabled
)
523 TRACE("Not Enabled\n");
527 LanguageProfile
.clsid
= *rclsid
;
528 LanguageProfile
.langid
= langid
;
529 LanguageProfile
.guidProfile
= *guidProfiles
;
531 hr
= add_active_textservice(&LanguageProfile
);
536 static HRESULT WINAPI
InputProcessorProfiles_GetActiveLanguageProfile(
537 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID
*plangid
,
540 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
541 TF_LANGUAGEPROFILE profile
;
543 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(rclsid
),plangid
,pguidProfile
);
545 if (!rclsid
|| !plangid
|| !pguidProfile
)
548 if (get_active_textservice(rclsid
, &profile
))
550 *plangid
= profile
.langid
;
551 *pguidProfile
= profile
.guidProfile
;
556 *pguidProfile
= GUID_NULL
;
561 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageProfileDescription(
562 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
563 REFGUID guidProfile
, BSTR
*pbstrProfile
)
565 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
566 FIXME("STUB:(%p)\n",This
);
570 static HRESULT WINAPI
InputProcessorProfiles_GetCurrentLanguage(
571 ITfInputProcessorProfiles
*iface
, LANGID
*plangid
)
573 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
574 TRACE("(%p) 0x%x\n",This
,This
->currentLanguage
);
579 *plangid
= This
->currentLanguage
;
584 static HRESULT WINAPI
InputProcessorProfiles_ChangeCurrentLanguage(
585 ITfInputProcessorProfiles
*iface
, LANGID langid
)
587 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
591 FIXME("STUB:(%p)\n",This
);
593 LIST_FOR_EACH(cursor
, &This
->LanguageProfileNotifySink
)
595 InputProcessorProfilesSink
* sink
= LIST_ENTRY(cursor
,InputProcessorProfilesSink
,entry
);
597 ITfLanguageProfileNotifySink_OnLanguageChange(sink
->interfaces
.pITfLanguageProfileNotifySink
, langid
, &accept
);
602 /* TODO: On successful language change call OnLanguageChanged sink */
606 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageList(
607 ITfInputProcessorProfiles
*iface
, LANGID
**ppLangId
, ULONG
*pulCount
)
609 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
610 FIXME("Semi-STUB:(%p)\n",This
);
611 *ppLangId
= CoTaskMemAlloc(sizeof(LANGID
));
612 **ppLangId
= This
->currentLanguage
;
617 static HRESULT WINAPI
InputProcessorProfiles_EnumLanguageProfiles(
618 ITfInputProcessorProfiles
*iface
, LANGID langid
,
619 IEnumTfLanguageProfiles
**ppEnum
)
621 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
622 TRACE("(%p) %x %p\n",This
,langid
,ppEnum
);
623 return EnumTfLanguageProfiles_Constructor(langid
, ppEnum
);
626 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfile(
627 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
628 REFGUID guidProfile
, BOOL fEnable
)
630 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
637 TRACE("(%p) %s %x %s %i\n",This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), fEnable
);
639 StringFromGUID2(rclsid
, buf
, 39);
640 StringFromGUID2(guidProfile
, buf2
, 39);
641 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
643 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
647 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
656 static HRESULT WINAPI
InputProcessorProfiles_IsEnabledLanguageProfile(
657 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
658 REFGUID guidProfile
, BOOL
*pfEnable
)
660 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
667 TRACE("(%p) %s, %i, %s, %p\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),pfEnable
);
672 StringFromGUID2(rclsid
, buf
, 39);
673 StringFromGUID2(guidProfile
, buf2
, 39);
674 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
676 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
680 DWORD count
= sizeof(DWORD
);
681 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
685 if (res
) /* Try Default */
687 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
691 DWORD count
= sizeof(DWORD
);
692 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
703 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfileByDefault(
704 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
705 REFGUID guidProfile
, BOOL fEnable
)
707 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
714 TRACE("(%p) %s %x %s %i\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),fEnable
);
716 StringFromGUID2(rclsid
, buf
, 39);
717 StringFromGUID2(guidProfile
, buf2
, 39);
718 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
720 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
724 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
733 static HRESULT WINAPI
InputProcessorProfiles_SubstituteKeyboardLayout(
734 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
735 REFGUID guidProfile
, HKL hKL
)
737 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
738 FIXME("STUB:(%p)\n",This
);
742 static const ITfInputProcessorProfilesVtbl InputProcessorProfilesVtbl
=
744 InputProcessorProfiles_QueryInterface
,
745 InputProcessorProfiles_AddRef
,
746 InputProcessorProfiles_Release
,
747 InputProcessorProfiles_Register
,
748 InputProcessorProfiles_Unregister
,
749 InputProcessorProfiles_AddLanguageProfile
,
750 InputProcessorProfiles_RemoveLanguageProfile
,
751 InputProcessorProfiles_EnumInputProcessorInfo
,
752 InputProcessorProfiles_GetDefaultLanguageProfile
,
753 InputProcessorProfiles_SetDefaultLanguageProfile
,
754 InputProcessorProfiles_ActivateLanguageProfile
,
755 InputProcessorProfiles_GetActiveLanguageProfile
,
756 InputProcessorProfiles_GetLanguageProfileDescription
,
757 InputProcessorProfiles_GetCurrentLanguage
,
758 InputProcessorProfiles_ChangeCurrentLanguage
,
759 InputProcessorProfiles_GetLanguageList
,
760 InputProcessorProfiles_EnumLanguageProfiles
,
761 InputProcessorProfiles_EnableLanguageProfile
,
762 InputProcessorProfiles_IsEnabledLanguageProfile
,
763 InputProcessorProfiles_EnableLanguageProfileByDefault
,
764 InputProcessorProfiles_SubstituteKeyboardLayout
767 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfileMgr(ITfInputProcessorProfileMgr
*iface
)
769 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfileMgr_iface
);
772 static HRESULT WINAPI
InputProcessorProfileMgr_QueryInterface(ITfInputProcessorProfileMgr
*iface
, REFIID riid
, void **ppv
)
774 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
775 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, riid
, ppv
);
778 static ULONG WINAPI
InputProcessorProfileMgr_AddRef(ITfInputProcessorProfileMgr
*iface
)
780 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
781 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
784 static ULONG WINAPI
InputProcessorProfileMgr_Release(ITfInputProcessorProfileMgr
*iface
)
786 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
787 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
790 static HRESULT WINAPI
InputProcessorProfileMgr_ActivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
791 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
793 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
794 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
795 debugstr_guid(guidProfile
), hkl
, dwFlags
);
799 static HRESULT WINAPI
InputProcessorProfileMgr_DeactivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
800 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
802 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
803 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
804 debugstr_guid(guidProfile
), hkl
, dwFlags
);
808 static HRESULT WINAPI
InputProcessorProfileMgr_GetProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
809 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, TF_INPUTPROCESSORPROFILE
*pProfile
)
811 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
812 FIXME("(%p)->(%d %x %s %s %p %p)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
813 debugstr_guid(guidProfile
), hkl
, pProfile
);
817 static HRESULT WINAPI
InputProcessorProfileMgr_EnumProfiles(ITfInputProcessorProfileMgr
*iface
, LANGID langid
,
818 IEnumTfInputProcessorProfiles
**ppEnum
)
820 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
821 EnumTfInputProcessorProfiles
*enum_profiles
;
823 TRACE("(%p)->(%x %p)\n", This
, langid
, ppEnum
);
825 enum_profiles
= HeapAlloc(GetProcessHeap(), 0, sizeof(*enum_profiles
));
827 return E_OUTOFMEMORY
;
829 enum_profiles
->IEnumTfInputProcessorProfiles_iface
.lpVtbl
= &EnumTfInputProcessorProfilesVtbl
;
830 enum_profiles
->ref
= 1;
832 *ppEnum
= &enum_profiles
->IEnumTfInputProcessorProfiles_iface
;
836 static HRESULT WINAPI
InputProcessorProfileMgr_ReleaseInputProcessor(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
839 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
840 FIXME("(%p)->(%s %x)\n", This
, debugstr_guid(rclsid
), dwFlags
);
844 static HRESULT WINAPI
InputProcessorProfileMgr_RegisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
845 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
, ULONG cchDesc
, const WCHAR
*pchIconFile
,
846 ULONG cchFile
, ULONG uIconIndex
, HKL hklsubstitute
, DWORD dwPreferredLayout
, BOOL bEnabledByDefault
,
849 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
850 FIXME("(%p)->(%s %x %s %s %d %s %u %u %p %x %x %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
),
851 debugstr_w(pchDesc
), cchDesc
, debugstr_w(pchIconFile
), cchFile
, uIconIndex
, hklsubstitute
, dwPreferredLayout
,
852 bEnabledByDefault
, dwFlags
);
856 static HRESULT WINAPI
InputProcessorProfileMgr_UnregisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
857 LANGID langid
, REFGUID guidProfile
, DWORD dwFlags
)
859 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
860 FIXME("(%p)->(%s %x %s %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), dwFlags
);
864 static HRESULT WINAPI
InputProcessorProfileMgr_GetActiveProfile(ITfInputProcessorProfileMgr
*iface
, REFGUID catid
,
865 TF_INPUTPROCESSORPROFILE
*pProfile
)
867 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
868 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(catid
), pProfile
);
872 static const ITfInputProcessorProfileMgrVtbl InputProcessorProfileMgrVtbl
= {
873 InputProcessorProfileMgr_QueryInterface
,
874 InputProcessorProfileMgr_AddRef
,
875 InputProcessorProfileMgr_Release
,
876 InputProcessorProfileMgr_ActivateProfile
,
877 InputProcessorProfileMgr_DeactivateProfile
,
878 InputProcessorProfileMgr_GetProfile
,
879 InputProcessorProfileMgr_EnumProfiles
,
880 InputProcessorProfileMgr_ReleaseInputProcessor
,
881 InputProcessorProfileMgr_RegisterProfile
,
882 InputProcessorProfileMgr_UnregisterProfile
,
883 InputProcessorProfileMgr_GetActiveProfile
886 /*****************************************************
887 * ITfSource functions
888 *****************************************************/
889 static HRESULT WINAPI
IPPSource_QueryInterface(ITfSource
*iface
, REFIID iid
, LPVOID
*ppvOut
)
891 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
892 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, iid
, ppvOut
);
895 static ULONG WINAPI
IPPSource_AddRef(ITfSource
*iface
)
897 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
898 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
901 static ULONG WINAPI
IPPSource_Release(ITfSource
*iface
)
903 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
904 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
907 static HRESULT WINAPI
IPPSource_AdviseSink(ITfSource
*iface
,
908 REFIID riid
, IUnknown
*punk
, DWORD
*pdwCookie
)
910 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
911 InputProcessorProfilesSink
*ipps
;
913 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(riid
),punk
,pdwCookie
);
915 if (!riid
|| !punk
|| !pdwCookie
)
918 if (IsEqualIID(riid
, &IID_ITfLanguageProfileNotifySink
))
920 ipps
= HeapAlloc(GetProcessHeap(),0,sizeof(InputProcessorProfilesSink
));
922 return E_OUTOFMEMORY
;
923 if (FAILED(IUnknown_QueryInterface(punk
, riid
, (LPVOID
*)&ipps
->interfaces
.pITfLanguageProfileNotifySink
)))
925 HeapFree(GetProcessHeap(),0,ipps
);
926 return CONNECT_E_CANNOTCONNECT
;
928 list_add_head(&This
->LanguageProfileNotifySink
,&ipps
->entry
);
929 *pdwCookie
= generate_Cookie(COOKIE_MAGIC_IPPSINK
, ipps
);
933 FIXME("(%p) Unhandled Sink: %s\n",This
,debugstr_guid(riid
));
937 TRACE("cookie %x\n",*pdwCookie
);
942 static HRESULT WINAPI
IPPSource_UnadviseSink(ITfSource
*iface
, DWORD pdwCookie
)
944 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
945 InputProcessorProfilesSink
*sink
;
947 TRACE("(%p) %x\n",This
,pdwCookie
);
949 if (get_Cookie_magic(pdwCookie
)!=COOKIE_MAGIC_IPPSINK
)
952 sink
= remove_Cookie(pdwCookie
);
954 return CONNECT_E_NOCONNECTION
;
956 list_remove(&sink
->entry
);
962 static const ITfSourceVtbl InputProcessorProfilesSourceVtbl
=
964 IPPSource_QueryInterface
,
967 IPPSource_AdviseSink
,
968 IPPSource_UnadviseSink
,
971 HRESULT
InputProcessorProfiles_Constructor(IUnknown
*pUnkOuter
, IUnknown
**ppOut
)
973 InputProcessorProfiles
*This
;
975 return CLASS_E_NOAGGREGATION
;
977 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(InputProcessorProfiles
));
979 return E_OUTOFMEMORY
;
981 This
->ITfInputProcessorProfiles_iface
.lpVtbl
= &InputProcessorProfilesVtbl
;
982 This
->ITfSource_iface
.lpVtbl
= &InputProcessorProfilesSourceVtbl
;
983 This
->ITfInputProcessorProfileMgr_iface
.lpVtbl
= &InputProcessorProfileMgrVtbl
;
985 This
->currentLanguage
= GetUserDefaultLCID();
987 list_init(&This
->LanguageProfileNotifySink
);
989 *ppOut
= (IUnknown
*)&This
->ITfInputProcessorProfiles_iface
;
990 TRACE("returning %p\n", *ppOut
);
994 /**************************************************
995 * IEnumGUID implementation for ITfInputProcessorProfiles::EnumInputProcessorInfo
996 **************************************************/
997 static void ProfilesEnumGuid_Destructor(ProfilesEnumGuid
*This
)
999 TRACE("destroying %p\n", This
);
1000 RegCloseKey(This
->key
);
1001 HeapFree(GetProcessHeap(),0,This
);
1004 static HRESULT WINAPI
ProfilesEnumGuid_QueryInterface(IEnumGUID
*iface
, REFIID iid
, LPVOID
*ppvOut
)
1006 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1009 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumGUID
))
1011 *ppvOut
= &This
->IEnumGUID_iface
;
1016 IEnumGUID_AddRef(iface
);
1020 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
1021 return E_NOINTERFACE
;
1024 static ULONG WINAPI
ProfilesEnumGuid_AddRef(IEnumGUID
*iface
)
1026 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1027 return InterlockedIncrement(&This
->refCount
);
1030 static ULONG WINAPI
ProfilesEnumGuid_Release(IEnumGUID
*iface
)
1032 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1035 ret
= InterlockedDecrement(&This
->refCount
);
1037 ProfilesEnumGuid_Destructor(This
);
1041 /*****************************************************
1042 * IEnumGuid functions
1043 *****************************************************/
1044 static HRESULT WINAPI
ProfilesEnumGuid_Next( LPENUMGUID iface
,
1045 ULONG celt
, GUID
*rgelt
, ULONG
*pceltFetched
)
1047 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1050 TRACE("(%p)\n",This
);
1052 if (rgelt
== NULL
) return E_POINTER
;
1054 if (This
->key
) while (fetched
< celt
)
1061 res
= RegEnumKeyExW(This
->key
, This
->next_index
, catid
, &cName
,
1062 NULL
, NULL
, NULL
, NULL
);
1063 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1064 ++(This
->next_index
);
1066 hr
= CLSIDFromString(catid
, rgelt
);
1067 if (FAILED(hr
)) continue;
1073 if (pceltFetched
) *pceltFetched
= fetched
;
1074 return fetched
== celt
? S_OK
: S_FALSE
;
1077 static HRESULT WINAPI
ProfilesEnumGuid_Skip( LPENUMGUID iface
, ULONG celt
)
1079 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1080 TRACE("(%p)\n",This
);
1082 This
->next_index
+= celt
;
1086 static HRESULT WINAPI
ProfilesEnumGuid_Reset( LPENUMGUID iface
)
1088 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1089 TRACE("(%p)\n",This
);
1090 This
->next_index
= 0;
1094 static HRESULT WINAPI
ProfilesEnumGuid_Clone( LPENUMGUID iface
,
1097 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1100 TRACE("(%p)\n",This
);
1102 if (ppenum
== NULL
) return E_POINTER
;
1104 res
= ProfilesEnumGuid_Constructor(ppenum
);
1107 ProfilesEnumGuid
*new_This
= impl_from_IEnumGUID(*ppenum
);
1108 new_This
->next_index
= This
->next_index
;
1113 static const IEnumGUIDVtbl EnumGUIDVtbl
=
1115 ProfilesEnumGuid_QueryInterface
,
1116 ProfilesEnumGuid_AddRef
,
1117 ProfilesEnumGuid_Release
,
1118 ProfilesEnumGuid_Next
,
1119 ProfilesEnumGuid_Skip
,
1120 ProfilesEnumGuid_Reset
,
1121 ProfilesEnumGuid_Clone
1124 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
)
1126 ProfilesEnumGuid
*This
;
1128 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(ProfilesEnumGuid
));
1130 return E_OUTOFMEMORY
;
1132 This
->IEnumGUID_iface
.lpVtbl
= &EnumGUIDVtbl
;
1135 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1136 KEY_READ
| KEY_WRITE
, NULL
, &This
->key
, NULL
) != ERROR_SUCCESS
)
1138 HeapFree(GetProcessHeap(), 0, This
);
1142 *ppOut
= &This
->IEnumGUID_iface
;
1143 TRACE("returning %p\n", *ppOut
);
1147 /**************************************************
1148 * IEnumTfLanguageProfiles implementation
1149 **************************************************/
1150 static void EnumTfLanguageProfiles_Destructor(EnumTfLanguageProfiles
*This
)
1152 TRACE("destroying %p\n", This
);
1153 RegCloseKey(This
->tipkey
);
1155 RegCloseKey(This
->langkey
);
1156 ITfCategoryMgr_Release(This
->catmgr
);
1157 HeapFree(GetProcessHeap(),0,This
);
1160 static HRESULT WINAPI
EnumTfLanguageProfiles_QueryInterface(IEnumTfLanguageProfiles
*iface
, REFIID iid
, LPVOID
*ppvOut
)
1162 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1166 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumTfLanguageProfiles
))
1168 *ppvOut
= &This
->IEnumTfLanguageProfiles_iface
;
1173 IEnumTfLanguageProfiles_AddRef(iface
);
1177 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
1178 return E_NOINTERFACE
;
1181 static ULONG WINAPI
EnumTfLanguageProfiles_AddRef(IEnumTfLanguageProfiles
*iface
)
1183 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1184 return InterlockedIncrement(&This
->refCount
);
1187 static ULONG WINAPI
EnumTfLanguageProfiles_Release(IEnumTfLanguageProfiles
*iface
)
1189 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1192 ret
= InterlockedDecrement(&This
->refCount
);
1194 EnumTfLanguageProfiles_Destructor(This
);
1198 /*****************************************************
1199 * IEnumGuid functions
1200 *****************************************************/
1201 static INT
next_LanguageProfile(EnumTfLanguageProfiles
*This
, CLSID clsid
, TF_LANGUAGEPROFILE
*tflp
)
1205 WCHAR profileid
[39];
1209 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1211 if (This
->langkey
== NULL
)
1213 sprintfW(fullkey
,fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1214 res
= RegOpenKeyExW(This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1217 This
->langkey
= NULL
;
1220 This
->lang_index
= 0;
1222 res
= RegEnumKeyExW(This
->langkey
, This
->lang_index
, profileid
, &cName
,
1223 NULL
, NULL
, NULL
, NULL
);
1224 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
)
1226 RegCloseKey(This
->langkey
);
1227 This
->langkey
= NULL
;
1230 ++(This
->lang_index
);
1234 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
1235 &GUID_TFCAT_TIP_SPEECH
,
1236 &GUID_TFCAT_TIP_HANDWRITING
};
1237 res
= CLSIDFromString(profileid
, &profile
);
1238 if (FAILED(res
)) return 0;
1240 tflp
->clsid
= clsid
;
1241 tflp
->langid
= This
->langid
;
1242 tflp
->fActive
= get_active_textservice(&clsid
, NULL
);
1243 tflp
->guidProfile
= profile
;
1244 if (ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1245 &tflp
->catid
, tipcats
, 3) != S_OK
)
1246 ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1247 &tflp
->catid
, NULL
, 0);
1253 static HRESULT WINAPI
EnumTfLanguageProfiles_Next(IEnumTfLanguageProfiles
*iface
,
1254 ULONG ulCount
, TF_LANGUAGEPROFILE
*pProfile
, ULONG
*pcFetch
)
1256 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1259 TRACE("(%p)\n",This
);
1261 if (pProfile
== NULL
) return E_POINTER
;
1263 if (This
->tipkey
) while (fetched
< ulCount
)
1270 res
= RegEnumKeyExW(This
->tipkey
, This
->tip_index
,
1271 This
->szwCurrentClsid
, &cName
, NULL
, NULL
, NULL
, NULL
);
1272 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1273 ++(This
->tip_index
);
1274 hr
= CLSIDFromString(This
->szwCurrentClsid
, &clsid
);
1275 if (FAILED(hr
)) continue;
1277 while ( fetched
< ulCount
)
1279 INT res
= next_LanguageProfile(This
, clsid
, pProfile
);
1292 if (pcFetch
) *pcFetch
= fetched
;
1293 return fetched
== ulCount
? S_OK
: S_FALSE
;
1296 static HRESULT WINAPI
EnumTfLanguageProfiles_Skip( IEnumTfLanguageProfiles
* iface
, ULONG celt
)
1298 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1299 FIXME("STUB (%p)\n",This
);
1303 static HRESULT WINAPI
EnumTfLanguageProfiles_Reset( IEnumTfLanguageProfiles
* iface
)
1305 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1306 TRACE("(%p)\n",This
);
1307 This
->tip_index
= 0;
1309 RegCloseKey(This
->langkey
);
1310 This
->langkey
= NULL
;
1311 This
->lang_index
= 0;
1315 static HRESULT WINAPI
EnumTfLanguageProfiles_Clone( IEnumTfLanguageProfiles
*iface
,
1316 IEnumTfLanguageProfiles
**ppenum
)
1318 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1321 TRACE("(%p)\n",This
);
1323 if (ppenum
== NULL
) return E_POINTER
;
1325 res
= EnumTfLanguageProfiles_Constructor(This
->langid
, ppenum
);
1328 EnumTfLanguageProfiles
*new_This
= (EnumTfLanguageProfiles
*)*ppenum
;
1329 new_This
->tip_index
= This
->tip_index
;
1330 lstrcpynW(new_This
->szwCurrentClsid
,This
->szwCurrentClsid
,39);
1335 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1337 sprintfW(fullkey
,fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1338 res
= RegOpenKeyExW(new_This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1339 new_This
->lang_index
= This
->lang_index
;
1345 static const IEnumTfLanguageProfilesVtbl EnumTfLanguageProfilesVtbl
=
1347 EnumTfLanguageProfiles_QueryInterface
,
1348 EnumTfLanguageProfiles_AddRef
,
1349 EnumTfLanguageProfiles_Release
,
1350 EnumTfLanguageProfiles_Clone
,
1351 EnumTfLanguageProfiles_Next
,
1352 EnumTfLanguageProfiles_Reset
,
1353 EnumTfLanguageProfiles_Skip
1356 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, IEnumTfLanguageProfiles
**ppOut
)
1359 EnumTfLanguageProfiles
*This
;
1361 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(EnumTfLanguageProfiles
));
1363 return E_OUTOFMEMORY
;
1365 This
->IEnumTfLanguageProfiles_iface
.lpVtbl
= &EnumTfLanguageProfilesVtbl
;
1367 This
->langid
= langid
;
1369 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&This
->catmgr
);
1372 HeapFree(GetProcessHeap(),0,This
);
1376 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1377 KEY_READ
| KEY_WRITE
, NULL
, &This
->tipkey
, NULL
) != ERROR_SUCCESS
)
1379 HeapFree(GetProcessHeap(), 0, This
);
1383 *ppOut
= &This
->IEnumTfLanguageProfiles_iface
;
1384 TRACE("returning %p\n", *ppOut
);