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"
37 #include "wine/unicode.h"
38 #include "wine/list.h"
41 #include "msctf_internal.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msctf
);
45 static const WCHAR szwLngp
[] = {'L','a','n','g','u','a','g','e','P','r','o','f','i','l','e',0};
46 static const WCHAR szwEnable
[] = {'E','n','a','b','l','e',0};
47 static const WCHAR szwTipfmt
[] = {'%','s','\\','%','s',0};
48 static const WCHAR szwFullLangfmt
[] = {'%','s','\\','%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
50 static const WCHAR szwAssemblies
[] = {'A','s','s','e','m','b','l','i','e','s',0};
51 static const WCHAR szwDefault
[] = {'D','e','f','a','u','l','t',0};
52 static const WCHAR szwProfile
[] = {'P','r','o','f','i','l','e',0};
53 static const WCHAR szwDefaultFmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
55 typedef struct tagInputProcessorProfilesSink
{
58 /* InputProcessorProfile Sinks */
60 ITfLanguageProfileNotifySink
*pITfLanguageProfileNotifySink
;
62 } InputProcessorProfilesSink
;
64 typedef struct tagInputProcessorProfiles
{
65 ITfInputProcessorProfiles ITfInputProcessorProfiles_iface
;
66 ITfSource ITfSource_iface
;
67 ITfInputProcessorProfileMgr ITfInputProcessorProfileMgr_iface
;
68 /* const ITfInputProcessorProfilesExVtbl *InputProcessorProfilesExVtbl; */
69 /* const ITfInputProcessorProfileSubstituteLayoutVtbl *InputProcessorProfileSubstituteLayoutVtbl; */
72 LANGID currentLanguage
;
74 struct list LanguageProfileNotifySink
;
75 } InputProcessorProfiles
;
77 typedef struct tagProfilesEnumGuid
{
78 IEnumGUID IEnumGUID_iface
;
85 typedef struct tagEnumTfLanguageProfiles
{
86 IEnumTfLanguageProfiles IEnumTfLanguageProfiles_iface
;
91 WCHAR szwCurrentClsid
[39];
97 ITfCategoryMgr
*catmgr
;
98 } EnumTfLanguageProfiles
;
101 IEnumTfInputProcessorProfiles IEnumTfInputProcessorProfiles_iface
;
103 } EnumTfInputProcessorProfiles
;
105 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
);
106 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, IEnumTfLanguageProfiles
**ppOut
);
108 static inline EnumTfInputProcessorProfiles
*impl_from_IEnumTfInputProcessorProfiles(IEnumTfInputProcessorProfiles
*iface
)
110 return CONTAINING_RECORD(iface
, EnumTfInputProcessorProfiles
, IEnumTfInputProcessorProfiles_iface
);
113 static HRESULT WINAPI
EnumTfInputProcessorProfiles_QueryInterface(IEnumTfInputProcessorProfiles
*iface
,
114 REFIID riid
, void **ppv
)
116 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
118 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
119 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
120 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
121 }else if(IsEqualGUID(riid
, &IID_IEnumTfInputProcessorProfiles
)) {
122 TRACE("(%p)->(IID_IEnumTfInputProcessorProfiles %p)\n", This
, ppv
);
123 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
126 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
127 return E_NOINTERFACE
;
130 IUnknown_AddRef((IUnknown
*)*ppv
);
134 static ULONG WINAPI
EnumTfInputProcessorProfiles_AddRef(IEnumTfInputProcessorProfiles
*iface
)
136 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
137 LONG ref
= InterlockedIncrement(&This
->ref
);
139 TRACE("(%p) ref=%d\n", This
, ref
);
144 static ULONG WINAPI
EnumTfInputProcessorProfiles_Release(IEnumTfInputProcessorProfiles
*iface
)
146 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
147 LONG ref
= InterlockedDecrement(&This
->ref
);
149 TRACE("(%p) ref=%d\n", This
, ref
);
152 HeapFree(GetProcessHeap(), 0, This
);
157 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Clone(IEnumTfInputProcessorProfiles
*iface
,
158 IEnumTfInputProcessorProfiles
**ret
)
160 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
161 FIXME("(%p)->(%p)\n", This
, ret
);
165 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Next(IEnumTfInputProcessorProfiles
*iface
, ULONG count
,
166 TF_INPUTPROCESSORPROFILE
*profile
, ULONG
*fetch
)
168 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
170 FIXME("(%p)->(%u %p %p)\n", This
, count
, profile
, fetch
);
177 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Reset(IEnumTfInputProcessorProfiles
*iface
)
179 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
180 FIXME("(%p)\n", This
);
184 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Skip(IEnumTfInputProcessorProfiles
*iface
, ULONG count
)
186 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
187 FIXME("(%p)->(%u)\n", This
, count
);
191 static const IEnumTfInputProcessorProfilesVtbl EnumTfInputProcessorProfilesVtbl
= {
192 EnumTfInputProcessorProfiles_QueryInterface
,
193 EnumTfInputProcessorProfiles_AddRef
,
194 EnumTfInputProcessorProfiles_Release
,
195 EnumTfInputProcessorProfiles_Clone
,
196 EnumTfInputProcessorProfiles_Next
,
197 EnumTfInputProcessorProfiles_Reset
,
198 EnumTfInputProcessorProfiles_Skip
201 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfiles(ITfInputProcessorProfiles
*iface
)
203 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfiles_iface
);
206 static inline InputProcessorProfiles
*impl_from_ITfSource(ITfSource
*iface
)
208 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfSource_iface
);
211 static inline ProfilesEnumGuid
*impl_from_IEnumGUID(IEnumGUID
*iface
)
213 return CONTAINING_RECORD(iface
, ProfilesEnumGuid
, IEnumGUID_iface
);
216 static inline EnumTfLanguageProfiles
*impl_from_IEnumTfLanguageProfiles(IEnumTfLanguageProfiles
*iface
)
218 return CONTAINING_RECORD(iface
, EnumTfLanguageProfiles
, IEnumTfLanguageProfiles_iface
);
221 static void free_sink(InputProcessorProfilesSink
*sink
)
223 IUnknown_Release(sink
->interfaces
.pIUnknown
);
224 HeapFree(GetProcessHeap(),0,sink
);
227 static void InputProcessorProfiles_Destructor(InputProcessorProfiles
*This
)
229 struct list
*cursor
, *cursor2
;
230 TRACE("destroying %p\n", This
);
233 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &This
->LanguageProfileNotifySink
)
235 InputProcessorProfilesSink
* sink
= LIST_ENTRY(cursor
,InputProcessorProfilesSink
,entry
);
240 HeapFree(GetProcessHeap(),0,This
);
243 static void add_userkey( REFCLSID rclsid
, LANGID langid
,
250 DWORD disposition
= 0;
255 StringFromGUID2(rclsid
, buf
, 39);
256 StringFromGUID2(guidProfile
, buf2
, 39);
257 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
259 res
= RegCreateKeyExW(HKEY_CURRENT_USER
,fullkey
, 0, NULL
, 0,
260 KEY_READ
| KEY_WRITE
, NULL
, &key
, &disposition
);
262 if (!res
&& disposition
== REG_CREATED_NEW_KEY
)
265 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
272 static HRESULT WINAPI
InputProcessorProfiles_QueryInterface(ITfInputProcessorProfiles
*iface
, REFIID iid
, void **ppv
)
274 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
276 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_ITfInputProcessorProfiles
))
278 *ppv
= &This
->ITfInputProcessorProfiles_iface
;
280 else if (IsEqualIID(iid
, &IID_ITfInputProcessorProfileMgr
))
282 *ppv
= &This
->ITfInputProcessorProfileMgr_iface
;
284 else if (IsEqualIID(iid
, &IID_ITfSource
))
286 *ppv
= &This
->ITfSource_iface
;
291 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
292 return E_NOINTERFACE
;
295 ITfInputProcessorProfiles_AddRef(iface
);
299 static ULONG WINAPI
InputProcessorProfiles_AddRef(ITfInputProcessorProfiles
*iface
)
301 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
302 return InterlockedIncrement(&This
->refCount
);
305 static ULONG WINAPI
InputProcessorProfiles_Release(ITfInputProcessorProfiles
*iface
)
307 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
310 ret
= InterlockedDecrement(&This
->refCount
);
312 InputProcessorProfiles_Destructor(This
);
316 /*****************************************************
317 * ITfInputProcessorProfiles functions
318 *****************************************************/
319 static HRESULT WINAPI
InputProcessorProfiles_Register(
320 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
322 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
327 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
329 StringFromGUID2(rclsid
, buf
, 39);
330 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
332 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, NULL
, 0,
333 KEY_READ
| KEY_WRITE
, NULL
, &tipkey
, NULL
) != ERROR_SUCCESS
)
341 static HRESULT WINAPI
InputProcessorProfiles_Unregister(
342 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
344 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
348 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
350 StringFromGUID2(rclsid
, buf
, 39);
351 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
353 RegDeleteTreeW(HKEY_LOCAL_MACHINE
, fullkey
);
354 RegDeleteTreeW(HKEY_CURRENT_USER
, fullkey
);
359 static HRESULT WINAPI
InputProcessorProfiles_AddLanguageProfile(
360 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
,
361 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
,
362 ULONG cchDesc
, const WCHAR
*pchIconFile
, ULONG cchFile
,
365 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
370 DWORD disposition
= 0;
372 static const WCHAR fmt2
[] = {'%','s','\\','0','x','%','0','8','x','\\','%','s',0};
373 static const WCHAR desc
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
374 static const WCHAR icnf
[] = {'I','c','o','n','F','i','l','e',0};
375 static const WCHAR icni
[] = {'I','c','o','n','I','n','d','e','x',0};
377 TRACE("(%p) %s %x %s %s %s %i\n",This
,debugstr_guid(rclsid
), langid
,
378 debugstr_guid(guidProfile
), debugstr_wn(pchDesc
,cchDesc
),
379 debugstr_wn(pchIconFile
,cchFile
),uIconIndex
);
381 StringFromGUID2(rclsid
, buf
, 39);
382 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
384 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, KEY_READ
| KEY_WRITE
,
385 &tipkey
) != ERROR_SUCCESS
)
388 StringFromGUID2(guidProfile
, buf
, 39);
389 sprintfW(fullkey
,fmt2
,szwLngp
,langid
,buf
);
391 res
= RegCreateKeyExW(tipkey
,fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
392 NULL
, &fmtkey
, &disposition
);
397 RegSetValueExW(fmtkey
, desc
, 0, REG_SZ
, (const BYTE
*)pchDesc
, cchDesc
* sizeof(WCHAR
));
398 RegSetValueExW(fmtkey
, icnf
, 0, REG_SZ
, (const BYTE
*)pchIconFile
, cchFile
* sizeof(WCHAR
));
399 RegSetValueExW(fmtkey
, icni
, 0, REG_DWORD
, (LPBYTE
)&uIconIndex
, sizeof(DWORD
));
400 if (disposition
== REG_CREATED_NEW_KEY
)
401 RegSetValueExW(fmtkey
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
404 add_userkey(rclsid
, langid
, guidProfile
);
414 static HRESULT WINAPI
InputProcessorProfiles_RemoveLanguageProfile(
415 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
418 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
419 FIXME("STUB:(%p)\n",This
);
423 static HRESULT WINAPI
InputProcessorProfiles_EnumInputProcessorInfo(
424 ITfInputProcessorProfiles
*iface
, IEnumGUID
**ppEnum
)
426 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
427 TRACE("(%p) %p\n",This
,ppEnum
);
428 return ProfilesEnumGuid_Constructor(ppEnum
);
431 static HRESULT WINAPI
InputProcessorProfiles_GetDefaultLanguageProfile(
432 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFGUID catid
,
433 CLSID
*pclsid
, GUID
*pguidProfile
)
435 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
442 TRACE("%p) %x %s %p %p\n",This
, langid
, debugstr_guid(catid
),pclsid
,pguidProfile
);
444 if (!catid
|| !pclsid
|| !pguidProfile
)
447 StringFromGUID2(catid
, buf
, 39);
448 sprintfW(fullkey
, szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
450 if (RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
,
451 &hkey
) != ERROR_SUCCESS
)
455 res
= RegQueryValueExW(hkey
, szwDefault
, 0, NULL
, (LPBYTE
)buf
, &count
);
456 if (res
!= ERROR_SUCCESS
)
461 CLSIDFromString(buf
,pclsid
);
463 res
= RegQueryValueExW(hkey
, szwProfile
, 0, NULL
, (LPBYTE
)buf
, &count
);
464 if (res
== ERROR_SUCCESS
)
465 CLSIDFromString(buf
,pguidProfile
);
472 static HRESULT WINAPI
InputProcessorProfiles_SetDefaultLanguageProfile(
473 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFCLSID rclsid
,
474 REFGUID guidProfiles
)
476 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
482 ITfCategoryMgr
*catmgr
;
483 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
484 &GUID_TFCAT_TIP_SPEECH
,
485 &GUID_TFCAT_TIP_HANDWRITING
};
487 TRACE("%p) %x %s %s\n",This
, langid
, debugstr_guid(rclsid
),debugstr_guid(guidProfiles
));
489 if (!rclsid
|| !guidProfiles
)
492 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&catmgr
);
497 if (ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
498 &catid
, tipcats
, 3) != S_OK
)
499 hr
= ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
501 ITfCategoryMgr_Release(catmgr
);
506 StringFromGUID2(&catid
, buf
, 39);
507 sprintfW(fullkey
, szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
509 if (RegCreateKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
510 NULL
, &hkey
, NULL
) != ERROR_SUCCESS
)
513 StringFromGUID2(rclsid
, buf
, 39);
514 RegSetValueExW(hkey
, szwDefault
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
515 StringFromGUID2(guidProfiles
, buf
, 39);
516 RegSetValueExW(hkey
, szwProfile
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
522 static HRESULT WINAPI
InputProcessorProfiles_ActivateLanguageProfile(
523 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
524 REFGUID guidProfiles
)
526 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
529 TF_LANGUAGEPROFILE LanguageProfile
;
531 TRACE("(%p) %s %x %s\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfiles
));
533 if (langid
!= This
->currentLanguage
) return E_INVALIDARG
;
535 if (get_active_textservice(rclsid
,NULL
))
537 TRACE("Already Active\n");
541 hr
= ITfInputProcessorProfiles_IsEnabledLanguageProfile(iface
, rclsid
,
542 langid
, guidProfiles
, &enabled
);
543 if (FAILED(hr
) || !enabled
)
545 TRACE("Not Enabled\n");
549 LanguageProfile
.clsid
= *rclsid
;
550 LanguageProfile
.langid
= langid
;
551 LanguageProfile
.guidProfile
= *guidProfiles
;
553 hr
= add_active_textservice(&LanguageProfile
);
558 static HRESULT WINAPI
InputProcessorProfiles_GetActiveLanguageProfile(
559 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID
*plangid
,
562 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
563 TF_LANGUAGEPROFILE profile
;
565 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(rclsid
),plangid
,pguidProfile
);
567 if (!rclsid
|| !plangid
|| !pguidProfile
)
570 if (get_active_textservice(rclsid
, &profile
))
572 *plangid
= profile
.langid
;
573 *pguidProfile
= profile
.guidProfile
;
578 *pguidProfile
= GUID_NULL
;
583 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageProfileDescription(
584 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
585 REFGUID guidProfile
, BSTR
*pbstrProfile
)
587 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
588 FIXME("STUB:(%p)\n",This
);
592 static HRESULT WINAPI
InputProcessorProfiles_GetCurrentLanguage(
593 ITfInputProcessorProfiles
*iface
, LANGID
*plangid
)
595 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
596 TRACE("(%p) 0x%x\n",This
,This
->currentLanguage
);
601 *plangid
= This
->currentLanguage
;
606 static HRESULT WINAPI
InputProcessorProfiles_ChangeCurrentLanguage(
607 ITfInputProcessorProfiles
*iface
, LANGID langid
)
609 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
613 FIXME("STUB:(%p)\n",This
);
615 LIST_FOR_EACH(cursor
, &This
->LanguageProfileNotifySink
)
617 InputProcessorProfilesSink
* sink
= LIST_ENTRY(cursor
,InputProcessorProfilesSink
,entry
);
619 ITfLanguageProfileNotifySink_OnLanguageChange(sink
->interfaces
.pITfLanguageProfileNotifySink
, langid
, &accept
);
624 /* TODO: On successful language change call OnLanguageChanged sink */
628 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageList(
629 ITfInputProcessorProfiles
*iface
, LANGID
**ppLangId
, ULONG
*pulCount
)
631 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
632 FIXME("Semi-STUB:(%p)\n",This
);
633 *ppLangId
= CoTaskMemAlloc(sizeof(LANGID
));
634 **ppLangId
= This
->currentLanguage
;
639 static HRESULT WINAPI
InputProcessorProfiles_EnumLanguageProfiles(
640 ITfInputProcessorProfiles
*iface
, LANGID langid
,
641 IEnumTfLanguageProfiles
**ppEnum
)
643 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
644 TRACE("(%p) %x %p\n",This
,langid
,ppEnum
);
645 return EnumTfLanguageProfiles_Constructor(langid
, ppEnum
);
648 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfile(
649 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
650 REFGUID guidProfile
, BOOL fEnable
)
652 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
659 TRACE("(%p) %s %x %s %i\n",This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), fEnable
);
661 StringFromGUID2(rclsid
, buf
, 39);
662 StringFromGUID2(guidProfile
, buf2
, 39);
663 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
665 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
669 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
678 static HRESULT WINAPI
InputProcessorProfiles_IsEnabledLanguageProfile(
679 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
680 REFGUID guidProfile
, BOOL
*pfEnable
)
682 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
689 TRACE("(%p) %s, %i, %s, %p\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),pfEnable
);
694 StringFromGUID2(rclsid
, buf
, 39);
695 StringFromGUID2(guidProfile
, buf2
, 39);
696 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
698 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
702 DWORD count
= sizeof(DWORD
);
703 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
707 if (res
) /* Try Default */
709 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
713 DWORD count
= sizeof(DWORD
);
714 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
725 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfileByDefault(
726 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
727 REFGUID guidProfile
, BOOL fEnable
)
729 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
736 TRACE("(%p) %s %x %s %i\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),fEnable
);
738 StringFromGUID2(rclsid
, buf
, 39);
739 StringFromGUID2(guidProfile
, buf2
, 39);
740 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
742 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
746 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
755 static HRESULT WINAPI
InputProcessorProfiles_SubstituteKeyboardLayout(
756 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
757 REFGUID guidProfile
, HKL hKL
)
759 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
760 FIXME("STUB:(%p)\n",This
);
764 static const ITfInputProcessorProfilesVtbl InputProcessorProfilesVtbl
=
766 InputProcessorProfiles_QueryInterface
,
767 InputProcessorProfiles_AddRef
,
768 InputProcessorProfiles_Release
,
769 InputProcessorProfiles_Register
,
770 InputProcessorProfiles_Unregister
,
771 InputProcessorProfiles_AddLanguageProfile
,
772 InputProcessorProfiles_RemoveLanguageProfile
,
773 InputProcessorProfiles_EnumInputProcessorInfo
,
774 InputProcessorProfiles_GetDefaultLanguageProfile
,
775 InputProcessorProfiles_SetDefaultLanguageProfile
,
776 InputProcessorProfiles_ActivateLanguageProfile
,
777 InputProcessorProfiles_GetActiveLanguageProfile
,
778 InputProcessorProfiles_GetLanguageProfileDescription
,
779 InputProcessorProfiles_GetCurrentLanguage
,
780 InputProcessorProfiles_ChangeCurrentLanguage
,
781 InputProcessorProfiles_GetLanguageList
,
782 InputProcessorProfiles_EnumLanguageProfiles
,
783 InputProcessorProfiles_EnableLanguageProfile
,
784 InputProcessorProfiles_IsEnabledLanguageProfile
,
785 InputProcessorProfiles_EnableLanguageProfileByDefault
,
786 InputProcessorProfiles_SubstituteKeyboardLayout
789 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfileMgr(ITfInputProcessorProfileMgr
*iface
)
791 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfileMgr_iface
);
794 static HRESULT WINAPI
InputProcessorProfileMgr_QueryInterface(ITfInputProcessorProfileMgr
*iface
, REFIID riid
, void **ppv
)
796 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
797 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, riid
, ppv
);
800 static ULONG WINAPI
InputProcessorProfileMgr_AddRef(ITfInputProcessorProfileMgr
*iface
)
802 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
803 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
806 static ULONG WINAPI
InputProcessorProfileMgr_Release(ITfInputProcessorProfileMgr
*iface
)
808 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
809 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
812 static HRESULT WINAPI
InputProcessorProfileMgr_ActivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
813 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
815 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
816 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
817 debugstr_guid(guidProfile
), hkl
, dwFlags
);
821 static HRESULT WINAPI
InputProcessorProfileMgr_DeactivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
822 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
824 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
825 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
826 debugstr_guid(guidProfile
), hkl
, dwFlags
);
830 static HRESULT WINAPI
InputProcessorProfileMgr_GetProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
831 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, TF_INPUTPROCESSORPROFILE
*pProfile
)
833 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
834 FIXME("(%p)->(%d %x %s %s %p %p)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
835 debugstr_guid(guidProfile
), hkl
, pProfile
);
839 static HRESULT WINAPI
InputProcessorProfileMgr_EnumProfiles(ITfInputProcessorProfileMgr
*iface
, LANGID langid
,
840 IEnumTfInputProcessorProfiles
**ppEnum
)
842 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
843 EnumTfInputProcessorProfiles
*enum_profiles
;
845 TRACE("(%p)->(%x %p)\n", This
, langid
, ppEnum
);
847 enum_profiles
= HeapAlloc(GetProcessHeap(), 0, sizeof(*enum_profiles
));
849 return E_OUTOFMEMORY
;
851 enum_profiles
->IEnumTfInputProcessorProfiles_iface
.lpVtbl
= &EnumTfInputProcessorProfilesVtbl
;
852 enum_profiles
->ref
= 1;
854 *ppEnum
= &enum_profiles
->IEnumTfInputProcessorProfiles_iface
;
858 static HRESULT WINAPI
InputProcessorProfileMgr_ReleaseInputProcessor(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
861 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
862 FIXME("(%p)->(%s %x)\n", This
, debugstr_guid(rclsid
), dwFlags
);
866 static HRESULT WINAPI
InputProcessorProfileMgr_RegisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
867 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
, ULONG cchDesc
, const WCHAR
*pchIconFile
,
868 ULONG cchFile
, ULONG uIconIndex
, HKL hklsubstitute
, DWORD dwPreferredLayout
, BOOL bEnabledByDefault
,
871 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
872 FIXME("(%p)->(%s %x %s %s %d %s %u %u %p %x %x %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
),
873 debugstr_w(pchDesc
), cchDesc
, debugstr_w(pchIconFile
), cchFile
, uIconIndex
, hklsubstitute
, dwPreferredLayout
,
874 bEnabledByDefault
, dwFlags
);
878 static HRESULT WINAPI
InputProcessorProfileMgr_UnregisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
879 LANGID langid
, REFGUID guidProfile
, DWORD dwFlags
)
881 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
882 FIXME("(%p)->(%s %x %s %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), dwFlags
);
886 static HRESULT WINAPI
InputProcessorProfileMgr_GetActiveProfile(ITfInputProcessorProfileMgr
*iface
, REFGUID catid
,
887 TF_INPUTPROCESSORPROFILE
*pProfile
)
889 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
890 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(catid
), pProfile
);
894 static const ITfInputProcessorProfileMgrVtbl InputProcessorProfileMgrVtbl
= {
895 InputProcessorProfileMgr_QueryInterface
,
896 InputProcessorProfileMgr_AddRef
,
897 InputProcessorProfileMgr_Release
,
898 InputProcessorProfileMgr_ActivateProfile
,
899 InputProcessorProfileMgr_DeactivateProfile
,
900 InputProcessorProfileMgr_GetProfile
,
901 InputProcessorProfileMgr_EnumProfiles
,
902 InputProcessorProfileMgr_ReleaseInputProcessor
,
903 InputProcessorProfileMgr_RegisterProfile
,
904 InputProcessorProfileMgr_UnregisterProfile
,
905 InputProcessorProfileMgr_GetActiveProfile
908 /*****************************************************
909 * ITfSource functions
910 *****************************************************/
911 static HRESULT WINAPI
IPPSource_QueryInterface(ITfSource
*iface
, REFIID iid
, LPVOID
*ppvOut
)
913 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
914 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, iid
, ppvOut
);
917 static ULONG WINAPI
IPPSource_AddRef(ITfSource
*iface
)
919 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
920 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
923 static ULONG WINAPI
IPPSource_Release(ITfSource
*iface
)
925 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
926 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
929 static HRESULT WINAPI
IPPSource_AdviseSink(ITfSource
*iface
,
930 REFIID riid
, IUnknown
*punk
, DWORD
*pdwCookie
)
932 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
933 InputProcessorProfilesSink
*ipps
;
935 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(riid
),punk
,pdwCookie
);
937 if (!riid
|| !punk
|| !pdwCookie
)
940 if (IsEqualIID(riid
, &IID_ITfLanguageProfileNotifySink
))
942 ipps
= HeapAlloc(GetProcessHeap(),0,sizeof(InputProcessorProfilesSink
));
944 return E_OUTOFMEMORY
;
945 if (FAILED(IUnknown_QueryInterface(punk
, riid
, (LPVOID
*)&ipps
->interfaces
.pITfLanguageProfileNotifySink
)))
947 HeapFree(GetProcessHeap(),0,ipps
);
948 return CONNECT_E_CANNOTCONNECT
;
950 list_add_head(&This
->LanguageProfileNotifySink
,&ipps
->entry
);
951 *pdwCookie
= generate_Cookie(COOKIE_MAGIC_IPPSINK
, ipps
);
955 FIXME("(%p) Unhandled Sink: %s\n",This
,debugstr_guid(riid
));
959 TRACE("cookie %x\n",*pdwCookie
);
964 static HRESULT WINAPI
IPPSource_UnadviseSink(ITfSource
*iface
, DWORD pdwCookie
)
966 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
967 InputProcessorProfilesSink
*sink
;
969 TRACE("(%p) %x\n",This
,pdwCookie
);
971 if (get_Cookie_magic(pdwCookie
)!=COOKIE_MAGIC_IPPSINK
)
974 sink
= remove_Cookie(pdwCookie
);
976 return CONNECT_E_NOCONNECTION
;
978 list_remove(&sink
->entry
);
984 static const ITfSourceVtbl InputProcessorProfilesSourceVtbl
=
986 IPPSource_QueryInterface
,
989 IPPSource_AdviseSink
,
990 IPPSource_UnadviseSink
,
993 HRESULT
InputProcessorProfiles_Constructor(IUnknown
*pUnkOuter
, IUnknown
**ppOut
)
995 InputProcessorProfiles
*This
;
997 return CLASS_E_NOAGGREGATION
;
999 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(InputProcessorProfiles
));
1001 return E_OUTOFMEMORY
;
1003 This
->ITfInputProcessorProfiles_iface
.lpVtbl
= &InputProcessorProfilesVtbl
;
1004 This
->ITfSource_iface
.lpVtbl
= &InputProcessorProfilesSourceVtbl
;
1005 This
->ITfInputProcessorProfileMgr_iface
.lpVtbl
= &InputProcessorProfileMgrVtbl
;
1007 This
->currentLanguage
= GetUserDefaultLCID();
1009 list_init(&This
->LanguageProfileNotifySink
);
1011 *ppOut
= (IUnknown
*)&This
->ITfInputProcessorProfiles_iface
;
1012 TRACE("returning %p\n", *ppOut
);
1016 /**************************************************
1017 * IEnumGUID implementation for ITfInputProcessorProfiles::EnumInputProcessorInfo
1018 **************************************************/
1019 static void ProfilesEnumGuid_Destructor(ProfilesEnumGuid
*This
)
1021 TRACE("destroying %p\n", This
);
1022 RegCloseKey(This
->key
);
1023 HeapFree(GetProcessHeap(),0,This
);
1026 static HRESULT WINAPI
ProfilesEnumGuid_QueryInterface(IEnumGUID
*iface
, REFIID iid
, LPVOID
*ppvOut
)
1028 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1031 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumGUID
))
1033 *ppvOut
= &This
->IEnumGUID_iface
;
1038 IEnumGUID_AddRef(iface
);
1042 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
1043 return E_NOINTERFACE
;
1046 static ULONG WINAPI
ProfilesEnumGuid_AddRef(IEnumGUID
*iface
)
1048 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1049 return InterlockedIncrement(&This
->refCount
);
1052 static ULONG WINAPI
ProfilesEnumGuid_Release(IEnumGUID
*iface
)
1054 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1057 ret
= InterlockedDecrement(&This
->refCount
);
1059 ProfilesEnumGuid_Destructor(This
);
1063 /*****************************************************
1064 * IEnumGuid functions
1065 *****************************************************/
1066 static HRESULT WINAPI
ProfilesEnumGuid_Next( LPENUMGUID iface
,
1067 ULONG celt
, GUID
*rgelt
, ULONG
*pceltFetched
)
1069 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1072 TRACE("(%p)\n",This
);
1074 if (rgelt
== NULL
) return E_POINTER
;
1076 if (This
->key
) while (fetched
< celt
)
1083 res
= RegEnumKeyExW(This
->key
, This
->next_index
, catid
, &cName
,
1084 NULL
, NULL
, NULL
, NULL
);
1085 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1086 ++(This
->next_index
);
1088 hr
= CLSIDFromString(catid
, rgelt
);
1089 if (FAILED(hr
)) continue;
1095 if (pceltFetched
) *pceltFetched
= fetched
;
1096 return fetched
== celt
? S_OK
: S_FALSE
;
1099 static HRESULT WINAPI
ProfilesEnumGuid_Skip( LPENUMGUID iface
, ULONG celt
)
1101 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1102 TRACE("(%p)\n",This
);
1104 This
->next_index
+= celt
;
1108 static HRESULT WINAPI
ProfilesEnumGuid_Reset( LPENUMGUID iface
)
1110 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1111 TRACE("(%p)\n",This
);
1112 This
->next_index
= 0;
1116 static HRESULT WINAPI
ProfilesEnumGuid_Clone( LPENUMGUID iface
,
1119 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1122 TRACE("(%p)\n",This
);
1124 if (ppenum
== NULL
) return E_POINTER
;
1126 res
= ProfilesEnumGuid_Constructor(ppenum
);
1129 ProfilesEnumGuid
*new_This
= impl_from_IEnumGUID(*ppenum
);
1130 new_This
->next_index
= This
->next_index
;
1135 static const IEnumGUIDVtbl EnumGUIDVtbl
=
1137 ProfilesEnumGuid_QueryInterface
,
1138 ProfilesEnumGuid_AddRef
,
1139 ProfilesEnumGuid_Release
,
1140 ProfilesEnumGuid_Next
,
1141 ProfilesEnumGuid_Skip
,
1142 ProfilesEnumGuid_Reset
,
1143 ProfilesEnumGuid_Clone
1146 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
)
1148 ProfilesEnumGuid
*This
;
1150 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(ProfilesEnumGuid
));
1152 return E_OUTOFMEMORY
;
1154 This
->IEnumGUID_iface
.lpVtbl
= &EnumGUIDVtbl
;
1157 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1158 KEY_READ
| KEY_WRITE
, NULL
, &This
->key
, NULL
) != ERROR_SUCCESS
)
1160 HeapFree(GetProcessHeap(), 0, This
);
1164 *ppOut
= &This
->IEnumGUID_iface
;
1165 TRACE("returning %p\n", *ppOut
);
1169 /**************************************************
1170 * IEnumTfLanguageProfiles implementation
1171 **************************************************/
1172 static void EnumTfLanguageProfiles_Destructor(EnumTfLanguageProfiles
*This
)
1174 TRACE("destroying %p\n", This
);
1175 RegCloseKey(This
->tipkey
);
1177 RegCloseKey(This
->langkey
);
1178 ITfCategoryMgr_Release(This
->catmgr
);
1179 HeapFree(GetProcessHeap(),0,This
);
1182 static HRESULT WINAPI
EnumTfLanguageProfiles_QueryInterface(IEnumTfLanguageProfiles
*iface
, REFIID iid
, LPVOID
*ppvOut
)
1184 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1188 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumTfLanguageProfiles
))
1190 *ppvOut
= &This
->IEnumTfLanguageProfiles_iface
;
1195 IEnumTfLanguageProfiles_AddRef(iface
);
1199 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
1200 return E_NOINTERFACE
;
1203 static ULONG WINAPI
EnumTfLanguageProfiles_AddRef(IEnumTfLanguageProfiles
*iface
)
1205 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1206 return InterlockedIncrement(&This
->refCount
);
1209 static ULONG WINAPI
EnumTfLanguageProfiles_Release(IEnumTfLanguageProfiles
*iface
)
1211 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1214 ret
= InterlockedDecrement(&This
->refCount
);
1216 EnumTfLanguageProfiles_Destructor(This
);
1220 /*****************************************************
1221 * IEnumGuid functions
1222 *****************************************************/
1223 static INT
next_LanguageProfile(EnumTfLanguageProfiles
*This
, CLSID clsid
, TF_LANGUAGEPROFILE
*tflp
)
1227 WCHAR profileid
[39];
1231 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1233 if (This
->langkey
== NULL
)
1235 sprintfW(fullkey
,fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1236 res
= RegOpenKeyExW(This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1239 This
->langkey
= NULL
;
1242 This
->lang_index
= 0;
1244 res
= RegEnumKeyExW(This
->langkey
, This
->lang_index
, profileid
, &cName
,
1245 NULL
, NULL
, NULL
, NULL
);
1246 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
)
1248 RegCloseKey(This
->langkey
);
1249 This
->langkey
= NULL
;
1252 ++(This
->lang_index
);
1256 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
1257 &GUID_TFCAT_TIP_SPEECH
,
1258 &GUID_TFCAT_TIP_HANDWRITING
};
1259 res
= CLSIDFromString(profileid
, &profile
);
1260 if (FAILED(res
)) return 0;
1262 tflp
->clsid
= clsid
;
1263 tflp
->langid
= This
->langid
;
1264 tflp
->fActive
= get_active_textservice(&clsid
, NULL
);
1265 tflp
->guidProfile
= profile
;
1266 if (ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1267 &tflp
->catid
, tipcats
, 3) != S_OK
)
1268 ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1269 &tflp
->catid
, NULL
, 0);
1275 static HRESULT WINAPI
EnumTfLanguageProfiles_Next(IEnumTfLanguageProfiles
*iface
,
1276 ULONG ulCount
, TF_LANGUAGEPROFILE
*pProfile
, ULONG
*pcFetch
)
1278 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1281 TRACE("(%p)\n",This
);
1283 if (pProfile
== NULL
) return E_POINTER
;
1285 if (This
->tipkey
) while (fetched
< ulCount
)
1292 res
= RegEnumKeyExW(This
->tipkey
, This
->tip_index
,
1293 This
->szwCurrentClsid
, &cName
, NULL
, NULL
, NULL
, NULL
);
1294 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1295 ++(This
->tip_index
);
1296 hr
= CLSIDFromString(This
->szwCurrentClsid
, &clsid
);
1297 if (FAILED(hr
)) continue;
1299 while ( fetched
< ulCount
)
1301 INT res
= next_LanguageProfile(This
, clsid
, pProfile
);
1314 if (pcFetch
) *pcFetch
= fetched
;
1315 return fetched
== ulCount
? S_OK
: S_FALSE
;
1318 static HRESULT WINAPI
EnumTfLanguageProfiles_Skip( IEnumTfLanguageProfiles
* iface
, ULONG celt
)
1320 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1321 FIXME("STUB (%p)\n",This
);
1325 static HRESULT WINAPI
EnumTfLanguageProfiles_Reset( IEnumTfLanguageProfiles
* iface
)
1327 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1328 TRACE("(%p)\n",This
);
1329 This
->tip_index
= 0;
1331 RegCloseKey(This
->langkey
);
1332 This
->langkey
= NULL
;
1333 This
->lang_index
= 0;
1337 static HRESULT WINAPI
EnumTfLanguageProfiles_Clone( IEnumTfLanguageProfiles
*iface
,
1338 IEnumTfLanguageProfiles
**ppenum
)
1340 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1343 TRACE("(%p)\n",This
);
1345 if (ppenum
== NULL
) return E_POINTER
;
1347 res
= EnumTfLanguageProfiles_Constructor(This
->langid
, ppenum
);
1350 EnumTfLanguageProfiles
*new_This
= (EnumTfLanguageProfiles
*)*ppenum
;
1351 new_This
->tip_index
= This
->tip_index
;
1352 lstrcpynW(new_This
->szwCurrentClsid
,This
->szwCurrentClsid
,39);
1357 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1359 sprintfW(fullkey
,fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1360 res
= RegOpenKeyExW(new_This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1361 new_This
->lang_index
= This
->lang_index
;
1367 static const IEnumTfLanguageProfilesVtbl EnumTfLanguageProfilesVtbl
=
1369 EnumTfLanguageProfiles_QueryInterface
,
1370 EnumTfLanguageProfiles_AddRef
,
1371 EnumTfLanguageProfiles_Release
,
1372 EnumTfLanguageProfiles_Clone
,
1373 EnumTfLanguageProfiles_Next
,
1374 EnumTfLanguageProfiles_Reset
,
1375 EnumTfLanguageProfiles_Skip
1378 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, IEnumTfLanguageProfiles
**ppOut
)
1381 EnumTfLanguageProfiles
*This
;
1383 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(EnumTfLanguageProfiles
));
1385 return E_OUTOFMEMORY
;
1387 This
->IEnumTfLanguageProfiles_iface
.lpVtbl
= &EnumTfLanguageProfilesVtbl
;
1389 This
->langid
= langid
;
1391 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&This
->catmgr
);
1394 HeapFree(GetProcessHeap(),0,This
);
1398 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1399 KEY_READ
| KEY_WRITE
, NULL
, &This
->tipkey
, NULL
) != ERROR_SUCCESS
)
1401 HeapFree(GetProcessHeap(), 0, This
);
1405 *ppOut
= &This
->IEnumTfLanguageProfiles_iface
;
1406 TRACE("returning %p\n", *ppOut
);