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
25 #include "wine/debug.h"
36 #include "msctf_internal.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(msctf
);
40 static const WCHAR szwLngp
[] = {'L','a','n','g','u','a','g','e','P','r','o','f','i','l','e',0};
41 static const WCHAR szwEnable
[] = {'E','n','a','b','l','e',0};
42 static const WCHAR szwTipfmt
[] = {'%','s','\\','%','s',0};
43 static const WCHAR szwFullLangfmt
[] = {'%','s','\\','%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
45 static const WCHAR szwAssemblies
[] = {'A','s','s','e','m','b','l','i','e','s',0};
46 static const WCHAR szwDefault
[] = {'D','e','f','a','u','l','t',0};
47 static const WCHAR szwProfile
[] = {'P','r','o','f','i','l','e',0};
48 static const WCHAR szwDefaultFmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
50 typedef struct tagInputProcessorProfiles
{
51 ITfInputProcessorProfiles ITfInputProcessorProfiles_iface
;
52 ITfSource ITfSource_iface
;
53 ITfInputProcessorProfileMgr ITfInputProcessorProfileMgr_iface
;
54 /* const ITfInputProcessorProfilesExVtbl *InputProcessorProfilesExVtbl; */
55 /* const ITfInputProcessorProfileSubstituteLayoutVtbl *InputProcessorProfileSubstituteLayoutVtbl; */
58 LANGID currentLanguage
;
60 struct list LanguageProfileNotifySink
;
61 } InputProcessorProfiles
;
63 typedef struct tagProfilesEnumGuid
{
64 IEnumGUID IEnumGUID_iface
;
71 typedef struct tagEnumTfLanguageProfiles
{
72 IEnumTfLanguageProfiles IEnumTfLanguageProfiles_iface
;
77 WCHAR szwCurrentClsid
[39];
83 ITfCategoryMgr
*catmgr
;
84 } EnumTfLanguageProfiles
;
87 IEnumTfInputProcessorProfiles IEnumTfInputProcessorProfiles_iface
;
89 } EnumTfInputProcessorProfiles
;
91 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
);
92 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, EnumTfLanguageProfiles
**out
);
94 static inline EnumTfInputProcessorProfiles
*impl_from_IEnumTfInputProcessorProfiles(IEnumTfInputProcessorProfiles
*iface
)
96 return CONTAINING_RECORD(iface
, EnumTfInputProcessorProfiles
, IEnumTfInputProcessorProfiles_iface
);
99 static HRESULT WINAPI
EnumTfInputProcessorProfiles_QueryInterface(IEnumTfInputProcessorProfiles
*iface
,
100 REFIID riid
, void **ppv
)
102 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
104 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
105 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
106 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
107 }else if(IsEqualGUID(riid
, &IID_IEnumTfInputProcessorProfiles
)) {
108 TRACE("(%p)->(IID_IEnumTfInputProcessorProfiles %p)\n", This
, ppv
);
109 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
112 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
113 return E_NOINTERFACE
;
116 IUnknown_AddRef((IUnknown
*)*ppv
);
120 static ULONG WINAPI
EnumTfInputProcessorProfiles_AddRef(IEnumTfInputProcessorProfiles
*iface
)
122 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
123 LONG ref
= InterlockedIncrement(&This
->ref
);
125 TRACE("(%p) ref=%d\n", This
, ref
);
130 static ULONG WINAPI
EnumTfInputProcessorProfiles_Release(IEnumTfInputProcessorProfiles
*iface
)
132 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
133 LONG ref
= InterlockedDecrement(&This
->ref
);
135 TRACE("(%p) ref=%d\n", This
, ref
);
138 HeapFree(GetProcessHeap(), 0, This
);
143 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Clone(IEnumTfInputProcessorProfiles
*iface
,
144 IEnumTfInputProcessorProfiles
**ret
)
146 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
147 FIXME("(%p)->(%p)\n", This
, ret
);
151 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Next(IEnumTfInputProcessorProfiles
*iface
, ULONG count
,
152 TF_INPUTPROCESSORPROFILE
*profile
, ULONG
*fetch
)
154 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
156 FIXME("(%p)->(%u %p %p)\n", This
, count
, profile
, fetch
);
163 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Reset(IEnumTfInputProcessorProfiles
*iface
)
165 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
166 FIXME("(%p)\n", This
);
170 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Skip(IEnumTfInputProcessorProfiles
*iface
, ULONG count
)
172 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
173 FIXME("(%p)->(%u)\n", This
, count
);
177 static const IEnumTfInputProcessorProfilesVtbl EnumTfInputProcessorProfilesVtbl
= {
178 EnumTfInputProcessorProfiles_QueryInterface
,
179 EnumTfInputProcessorProfiles_AddRef
,
180 EnumTfInputProcessorProfiles_Release
,
181 EnumTfInputProcessorProfiles_Clone
,
182 EnumTfInputProcessorProfiles_Next
,
183 EnumTfInputProcessorProfiles_Reset
,
184 EnumTfInputProcessorProfiles_Skip
187 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfiles(ITfInputProcessorProfiles
*iface
)
189 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfiles_iface
);
192 static inline InputProcessorProfiles
*impl_from_ITfSource(ITfSource
*iface
)
194 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfSource_iface
);
197 static inline ProfilesEnumGuid
*impl_from_IEnumGUID(IEnumGUID
*iface
)
199 return CONTAINING_RECORD(iface
, ProfilesEnumGuid
, IEnumGUID_iface
);
202 static inline EnumTfLanguageProfiles
*impl_from_IEnumTfLanguageProfiles(IEnumTfLanguageProfiles
*iface
)
204 return CONTAINING_RECORD(iface
, EnumTfLanguageProfiles
, IEnumTfLanguageProfiles_iface
);
207 static void InputProcessorProfiles_Destructor(InputProcessorProfiles
*This
)
209 TRACE("destroying %p\n", This
);
211 free_sinks(&This
->LanguageProfileNotifySink
);
212 HeapFree(GetProcessHeap(),0,This
);
215 static void add_userkey( REFCLSID rclsid
, LANGID langid
,
222 DWORD disposition
= 0;
227 StringFromGUID2(rclsid
, buf
, 39);
228 StringFromGUID2(guidProfile
, buf2
, 39);
229 swprintf(fullkey
,ARRAY_SIZE(fullkey
),szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
231 res
= RegCreateKeyExW(HKEY_CURRENT_USER
,fullkey
, 0, NULL
, 0,
232 KEY_READ
| KEY_WRITE
, NULL
, &key
, &disposition
);
234 if (!res
&& disposition
== REG_CREATED_NEW_KEY
)
237 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
244 static HRESULT WINAPI
InputProcessorProfiles_QueryInterface(ITfInputProcessorProfiles
*iface
, REFIID iid
, void **ppv
)
246 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
248 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_ITfInputProcessorProfiles
))
250 *ppv
= &This
->ITfInputProcessorProfiles_iface
;
252 else if (IsEqualIID(iid
, &IID_ITfInputProcessorProfileMgr
))
254 *ppv
= &This
->ITfInputProcessorProfileMgr_iface
;
256 else if (IsEqualIID(iid
, &IID_ITfSource
))
258 *ppv
= &This
->ITfSource_iface
;
263 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
264 return E_NOINTERFACE
;
267 ITfInputProcessorProfiles_AddRef(iface
);
271 static ULONG WINAPI
InputProcessorProfiles_AddRef(ITfInputProcessorProfiles
*iface
)
273 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
274 return InterlockedIncrement(&This
->refCount
);
277 static ULONG WINAPI
InputProcessorProfiles_Release(ITfInputProcessorProfiles
*iface
)
279 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
282 ret
= InterlockedDecrement(&This
->refCount
);
284 InputProcessorProfiles_Destructor(This
);
288 /*****************************************************
289 * ITfInputProcessorProfiles functions
290 *****************************************************/
291 static HRESULT WINAPI
InputProcessorProfiles_Register(
292 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
294 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
299 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
301 StringFromGUID2(rclsid
, buf
, 39);
302 swprintf(fullkey
,ARRAY_SIZE(fullkey
),szwTipfmt
,szwSystemTIPKey
,buf
);
304 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, NULL
, 0,
305 KEY_READ
| KEY_WRITE
, NULL
, &tipkey
, NULL
) != ERROR_SUCCESS
)
313 static HRESULT WINAPI
InputProcessorProfiles_Unregister(
314 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
316 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
320 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
322 StringFromGUID2(rclsid
, buf
, 39);
323 swprintf(fullkey
,ARRAY_SIZE(fullkey
),szwTipfmt
,szwSystemTIPKey
,buf
);
325 RegDeleteTreeW(HKEY_LOCAL_MACHINE
, fullkey
);
326 RegDeleteTreeW(HKEY_CURRENT_USER
, fullkey
);
331 static HRESULT WINAPI
InputProcessorProfiles_AddLanguageProfile(
332 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
,
333 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
,
334 ULONG cchDesc
, const WCHAR
*pchIconFile
, ULONG cchFile
,
337 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
342 DWORD disposition
= 0;
344 static const WCHAR fmt2
[] = {'%','s','\\','0','x','%','0','8','x','\\','%','s',0};
345 static const WCHAR desc
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
346 static const WCHAR icnf
[] = {'I','c','o','n','F','i','l','e',0};
347 static const WCHAR icni
[] = {'I','c','o','n','I','n','d','e','x',0};
349 TRACE("(%p) %s %x %s %s %s %i\n",This
,debugstr_guid(rclsid
), langid
,
350 debugstr_guid(guidProfile
), debugstr_wn(pchDesc
,cchDesc
),
351 debugstr_wn(pchIconFile
,cchFile
),uIconIndex
);
353 StringFromGUID2(rclsid
, buf
, 39);
354 swprintf(fullkey
,ARRAY_SIZE(fullkey
),szwTipfmt
,szwSystemTIPKey
,buf
);
356 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, KEY_READ
| KEY_WRITE
,
357 &tipkey
) != ERROR_SUCCESS
)
360 StringFromGUID2(guidProfile
, buf
, 39);
361 swprintf(fullkey
,ARRAY_SIZE(fullkey
),fmt2
,szwLngp
,langid
,buf
);
363 res
= RegCreateKeyExW(tipkey
,fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
364 NULL
, &fmtkey
, &disposition
);
369 RegSetValueExW(fmtkey
, desc
, 0, REG_SZ
, (const BYTE
*)pchDesc
, cchDesc
* sizeof(WCHAR
));
370 RegSetValueExW(fmtkey
, icnf
, 0, REG_SZ
, (const BYTE
*)pchIconFile
, cchFile
* sizeof(WCHAR
));
371 RegSetValueExW(fmtkey
, icni
, 0, REG_DWORD
, (LPBYTE
)&uIconIndex
, sizeof(DWORD
));
372 if (disposition
== REG_CREATED_NEW_KEY
)
373 RegSetValueExW(fmtkey
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
376 add_userkey(rclsid
, langid
, guidProfile
);
386 static HRESULT WINAPI
InputProcessorProfiles_RemoveLanguageProfile(
387 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
390 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
391 FIXME("STUB:(%p)\n",This
);
395 static HRESULT WINAPI
InputProcessorProfiles_EnumInputProcessorInfo(
396 ITfInputProcessorProfiles
*iface
, IEnumGUID
**ppEnum
)
398 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
399 TRACE("(%p) %p\n",This
,ppEnum
);
400 return ProfilesEnumGuid_Constructor(ppEnum
);
403 static HRESULT WINAPI
InputProcessorProfiles_GetDefaultLanguageProfile(
404 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFGUID catid
,
405 CLSID
*pclsid
, GUID
*pguidProfile
)
407 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
414 TRACE("%p) %x %s %p %p\n",This
, langid
, debugstr_guid(catid
),pclsid
,pguidProfile
);
416 if (!catid
|| !pclsid
|| !pguidProfile
)
419 StringFromGUID2(catid
, buf
, 39);
420 swprintf(fullkey
, ARRAY_SIZE(fullkey
), szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
422 if (RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
,
423 &hkey
) != ERROR_SUCCESS
)
427 res
= RegQueryValueExW(hkey
, szwDefault
, 0, NULL
, (LPBYTE
)buf
, &count
);
428 if (res
!= ERROR_SUCCESS
)
433 CLSIDFromString(buf
,pclsid
);
435 res
= RegQueryValueExW(hkey
, szwProfile
, 0, NULL
, (LPBYTE
)buf
, &count
);
436 if (res
== ERROR_SUCCESS
)
437 CLSIDFromString(buf
,pguidProfile
);
444 static HRESULT WINAPI
InputProcessorProfiles_SetDefaultLanguageProfile(
445 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFCLSID rclsid
,
446 REFGUID guidProfiles
)
448 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
454 ITfCategoryMgr
*catmgr
;
455 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
456 &GUID_TFCAT_TIP_SPEECH
,
457 &GUID_TFCAT_TIP_HANDWRITING
};
459 TRACE("%p) %x %s %s\n",This
, langid
, debugstr_guid(rclsid
),debugstr_guid(guidProfiles
));
461 if (!rclsid
|| !guidProfiles
)
464 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&catmgr
);
469 if (ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
470 &catid
, tipcats
, 3) != S_OK
)
471 hr
= ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
473 ITfCategoryMgr_Release(catmgr
);
478 StringFromGUID2(&catid
, buf
, 39);
479 swprintf(fullkey
, ARRAY_SIZE(fullkey
), szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
481 if (RegCreateKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
482 NULL
, &hkey
, NULL
) != ERROR_SUCCESS
)
485 StringFromGUID2(rclsid
, buf
, 39);
486 RegSetValueExW(hkey
, szwDefault
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
487 StringFromGUID2(guidProfiles
, buf
, 39);
488 RegSetValueExW(hkey
, szwProfile
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
494 static HRESULT WINAPI
InputProcessorProfiles_ActivateLanguageProfile(
495 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
496 REFGUID guidProfiles
)
498 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
501 TF_LANGUAGEPROFILE LanguageProfile
;
503 TRACE("(%p) %s %x %s\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfiles
));
505 if (langid
!= This
->currentLanguage
) return E_INVALIDARG
;
507 if (get_active_textservice(rclsid
,NULL
))
509 TRACE("Already Active\n");
513 hr
= ITfInputProcessorProfiles_IsEnabledLanguageProfile(iface
, rclsid
,
514 langid
, guidProfiles
, &enabled
);
515 if (FAILED(hr
) || !enabled
)
517 TRACE("Not Enabled\n");
521 LanguageProfile
.clsid
= *rclsid
;
522 LanguageProfile
.langid
= langid
;
523 LanguageProfile
.guidProfile
= *guidProfiles
;
524 LanguageProfile
.fActive
= TRUE
;
526 return add_active_textservice(&LanguageProfile
);
529 static HRESULT WINAPI
InputProcessorProfiles_GetActiveLanguageProfile(
530 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID
*plangid
,
533 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
534 TF_LANGUAGEPROFILE profile
;
536 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(rclsid
),plangid
,pguidProfile
);
538 if (!rclsid
|| !plangid
|| !pguidProfile
)
541 if (get_active_textservice(rclsid
, &profile
))
543 *plangid
= profile
.langid
;
544 *pguidProfile
= profile
.guidProfile
;
549 *pguidProfile
= GUID_NULL
;
554 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageProfileDescription(
555 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
556 REFGUID guidProfile
, BSTR
*pbstrProfile
)
558 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
559 FIXME("STUB:(%p)\n",This
);
563 static HRESULT WINAPI
InputProcessorProfiles_GetCurrentLanguage(
564 ITfInputProcessorProfiles
*iface
, LANGID
*plangid
)
566 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
567 TRACE("(%p) 0x%x\n",This
,This
->currentLanguage
);
572 *plangid
= This
->currentLanguage
;
577 static HRESULT WINAPI
InputProcessorProfiles_ChangeCurrentLanguage(
578 ITfInputProcessorProfiles
*iface
, LANGID langid
)
580 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
581 ITfLanguageProfileNotifySink
*sink
;
585 FIXME("STUB:(%p)\n",This
);
587 SINK_FOR_EACH(cursor
, &This
->LanguageProfileNotifySink
, ITfLanguageProfileNotifySink
, sink
)
590 ITfLanguageProfileNotifySink_OnLanguageChange(sink
, langid
, &accept
);
595 /* TODO: On successful language change call OnLanguageChanged sink */
599 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageList(
600 ITfInputProcessorProfiles
*iface
, LANGID
**ppLangId
, ULONG
*pulCount
)
602 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
603 FIXME("Semi-STUB:(%p)\n",This
);
604 *ppLangId
= CoTaskMemAlloc(sizeof(LANGID
));
605 **ppLangId
= This
->currentLanguage
;
610 static HRESULT WINAPI
InputProcessorProfiles_EnumLanguageProfiles(
611 ITfInputProcessorProfiles
*iface
, LANGID langid
,
612 IEnumTfLanguageProfiles
**ppEnum
)
614 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
615 EnumTfLanguageProfiles
*profenum
;
618 TRACE("(%p) %x %p\n",This
,langid
,ppEnum
);
622 hr
= EnumTfLanguageProfiles_Constructor(langid
, &profenum
);
623 *ppEnum
= &profenum
->IEnumTfLanguageProfiles_iface
;
628 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfile(
629 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
630 REFGUID guidProfile
, BOOL fEnable
)
632 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
639 TRACE("(%p) %s %x %s %i\n",This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), fEnable
);
641 StringFromGUID2(rclsid
, buf
, 39);
642 StringFromGUID2(guidProfile
, buf2
, 39);
643 swprintf(fullkey
,ARRAY_SIZE(fullkey
),szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
645 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
649 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
658 static HRESULT WINAPI
InputProcessorProfiles_IsEnabledLanguageProfile(
659 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
660 REFGUID guidProfile
, BOOL
*pfEnable
)
662 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
669 TRACE("(%p) %s, %i, %s, %p\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),pfEnable
);
674 StringFromGUID2(rclsid
, buf
, 39);
675 StringFromGUID2(guidProfile
, buf2
, 39);
676 swprintf(fullkey
,ARRAY_SIZE(fullkey
),szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
678 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
682 DWORD count
= sizeof(DWORD
);
683 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
687 if (res
) /* Try Default */
689 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
693 DWORD count
= sizeof(DWORD
);
694 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
705 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfileByDefault(
706 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
707 REFGUID guidProfile
, BOOL fEnable
)
709 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
716 TRACE("(%p) %s %x %s %i\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),fEnable
);
718 StringFromGUID2(rclsid
, buf
, 39);
719 StringFromGUID2(guidProfile
, buf2
, 39);
720 swprintf(fullkey
,ARRAY_SIZE(fullkey
),szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
722 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
726 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
735 static HRESULT WINAPI
InputProcessorProfiles_SubstituteKeyboardLayout(
736 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
737 REFGUID guidProfile
, HKL hKL
)
739 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
740 FIXME("STUB:(%p)\n",This
);
744 static const ITfInputProcessorProfilesVtbl InputProcessorProfilesVtbl
=
746 InputProcessorProfiles_QueryInterface
,
747 InputProcessorProfiles_AddRef
,
748 InputProcessorProfiles_Release
,
749 InputProcessorProfiles_Register
,
750 InputProcessorProfiles_Unregister
,
751 InputProcessorProfiles_AddLanguageProfile
,
752 InputProcessorProfiles_RemoveLanguageProfile
,
753 InputProcessorProfiles_EnumInputProcessorInfo
,
754 InputProcessorProfiles_GetDefaultLanguageProfile
,
755 InputProcessorProfiles_SetDefaultLanguageProfile
,
756 InputProcessorProfiles_ActivateLanguageProfile
,
757 InputProcessorProfiles_GetActiveLanguageProfile
,
758 InputProcessorProfiles_GetLanguageProfileDescription
,
759 InputProcessorProfiles_GetCurrentLanguage
,
760 InputProcessorProfiles_ChangeCurrentLanguage
,
761 InputProcessorProfiles_GetLanguageList
,
762 InputProcessorProfiles_EnumLanguageProfiles
,
763 InputProcessorProfiles_EnableLanguageProfile
,
764 InputProcessorProfiles_IsEnabledLanguageProfile
,
765 InputProcessorProfiles_EnableLanguageProfileByDefault
,
766 InputProcessorProfiles_SubstituteKeyboardLayout
769 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfileMgr(ITfInputProcessorProfileMgr
*iface
)
771 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfileMgr_iface
);
774 static HRESULT WINAPI
InputProcessorProfileMgr_QueryInterface(ITfInputProcessorProfileMgr
*iface
, REFIID riid
, void **ppv
)
776 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
777 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, riid
, ppv
);
780 static ULONG WINAPI
InputProcessorProfileMgr_AddRef(ITfInputProcessorProfileMgr
*iface
)
782 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
783 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
786 static ULONG WINAPI
InputProcessorProfileMgr_Release(ITfInputProcessorProfileMgr
*iface
)
788 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
789 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
792 static HRESULT WINAPI
InputProcessorProfileMgr_ActivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
793 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
795 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
796 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
797 debugstr_guid(guidProfile
), hkl
, dwFlags
);
801 static HRESULT WINAPI
InputProcessorProfileMgr_DeactivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
802 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
804 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
805 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
806 debugstr_guid(guidProfile
), hkl
, dwFlags
);
810 static HRESULT WINAPI
InputProcessorProfileMgr_GetProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
811 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, TF_INPUTPROCESSORPROFILE
*pProfile
)
813 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
814 FIXME("(%p)->(%d %x %s %s %p %p)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
815 debugstr_guid(guidProfile
), hkl
, pProfile
);
819 static HRESULT WINAPI
InputProcessorProfileMgr_EnumProfiles(ITfInputProcessorProfileMgr
*iface
, LANGID langid
,
820 IEnumTfInputProcessorProfiles
**ppEnum
)
822 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
823 EnumTfInputProcessorProfiles
*enum_profiles
;
825 TRACE("(%p)->(%x %p)\n", This
, langid
, ppEnum
);
827 enum_profiles
= HeapAlloc(GetProcessHeap(), 0, sizeof(*enum_profiles
));
829 return E_OUTOFMEMORY
;
831 enum_profiles
->IEnumTfInputProcessorProfiles_iface
.lpVtbl
= &EnumTfInputProcessorProfilesVtbl
;
832 enum_profiles
->ref
= 1;
834 *ppEnum
= &enum_profiles
->IEnumTfInputProcessorProfiles_iface
;
838 static HRESULT WINAPI
InputProcessorProfileMgr_ReleaseInputProcessor(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
841 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
842 FIXME("(%p)->(%s %x)\n", This
, debugstr_guid(rclsid
), dwFlags
);
846 static HRESULT WINAPI
InputProcessorProfileMgr_RegisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
847 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
, ULONG cchDesc
, const WCHAR
*pchIconFile
,
848 ULONG cchFile
, ULONG uIconIndex
, HKL hklsubstitute
, DWORD dwPreferredLayout
, BOOL bEnabledByDefault
,
851 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
852 FIXME("(%p)->(%s %x %s %s %d %s %u %u %p %x %x %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
),
853 debugstr_w(pchDesc
), cchDesc
, debugstr_w(pchIconFile
), cchFile
, uIconIndex
, hklsubstitute
, dwPreferredLayout
,
854 bEnabledByDefault
, dwFlags
);
858 static HRESULT WINAPI
InputProcessorProfileMgr_UnregisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
859 LANGID langid
, REFGUID guidProfile
, DWORD dwFlags
)
861 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
862 FIXME("(%p)->(%s %x %s %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), dwFlags
);
866 static HRESULT WINAPI
InputProcessorProfileMgr_GetActiveProfile(ITfInputProcessorProfileMgr
*iface
, REFGUID catid
,
867 TF_INPUTPROCESSORPROFILE
*pProfile
)
869 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
870 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(catid
), pProfile
);
874 static const ITfInputProcessorProfileMgrVtbl InputProcessorProfileMgrVtbl
= {
875 InputProcessorProfileMgr_QueryInterface
,
876 InputProcessorProfileMgr_AddRef
,
877 InputProcessorProfileMgr_Release
,
878 InputProcessorProfileMgr_ActivateProfile
,
879 InputProcessorProfileMgr_DeactivateProfile
,
880 InputProcessorProfileMgr_GetProfile
,
881 InputProcessorProfileMgr_EnumProfiles
,
882 InputProcessorProfileMgr_ReleaseInputProcessor
,
883 InputProcessorProfileMgr_RegisterProfile
,
884 InputProcessorProfileMgr_UnregisterProfile
,
885 InputProcessorProfileMgr_GetActiveProfile
888 /*****************************************************
889 * ITfSource functions
890 *****************************************************/
891 static HRESULT WINAPI
IPPSource_QueryInterface(ITfSource
*iface
, REFIID iid
, LPVOID
*ppvOut
)
893 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
894 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, iid
, ppvOut
);
897 static ULONG WINAPI
IPPSource_AddRef(ITfSource
*iface
)
899 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
900 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
903 static ULONG WINAPI
IPPSource_Release(ITfSource
*iface
)
905 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
906 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
909 static HRESULT WINAPI
IPPSource_AdviseSink(ITfSource
*iface
,
910 REFIID riid
, IUnknown
*punk
, DWORD
*pdwCookie
)
912 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
914 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(riid
),punk
,pdwCookie
);
916 if (!riid
|| !punk
|| !pdwCookie
)
919 if (IsEqualIID(riid
, &IID_ITfLanguageProfileNotifySink
))
920 return advise_sink(&This
->LanguageProfileNotifySink
, &IID_ITfLanguageProfileNotifySink
,
921 COOKIE_MAGIC_IPPSINK
, punk
, pdwCookie
);
923 FIXME("(%p) Unhandled Sink: %s\n",This
,debugstr_guid(riid
));
927 static HRESULT WINAPI
IPPSource_UnadviseSink(ITfSource
*iface
, DWORD pdwCookie
)
929 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
931 TRACE("(%p) %x\n",This
,pdwCookie
);
933 if (get_Cookie_magic(pdwCookie
)!=COOKIE_MAGIC_IPPSINK
)
936 return unadvise_sink(pdwCookie
);
939 static const ITfSourceVtbl InputProcessorProfilesSourceVtbl
=
941 IPPSource_QueryInterface
,
944 IPPSource_AdviseSink
,
945 IPPSource_UnadviseSink
,
948 HRESULT
InputProcessorProfiles_Constructor(IUnknown
*pUnkOuter
, IUnknown
**ppOut
)
950 InputProcessorProfiles
*This
;
952 return CLASS_E_NOAGGREGATION
;
954 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(InputProcessorProfiles
));
956 return E_OUTOFMEMORY
;
958 This
->ITfInputProcessorProfiles_iface
.lpVtbl
= &InputProcessorProfilesVtbl
;
959 This
->ITfSource_iface
.lpVtbl
= &InputProcessorProfilesSourceVtbl
;
960 This
->ITfInputProcessorProfileMgr_iface
.lpVtbl
= &InputProcessorProfileMgrVtbl
;
962 This
->currentLanguage
= GetUserDefaultLCID();
964 list_init(&This
->LanguageProfileNotifySink
);
966 *ppOut
= (IUnknown
*)&This
->ITfInputProcessorProfiles_iface
;
967 TRACE("returning %p\n", *ppOut
);
971 /**************************************************
972 * IEnumGUID implementation for ITfInputProcessorProfiles::EnumInputProcessorInfo
973 **************************************************/
974 static void ProfilesEnumGuid_Destructor(ProfilesEnumGuid
*This
)
976 TRACE("destroying %p\n", This
);
977 RegCloseKey(This
->key
);
978 HeapFree(GetProcessHeap(),0,This
);
981 static HRESULT WINAPI
ProfilesEnumGuid_QueryInterface(IEnumGUID
*iface
, REFIID iid
, LPVOID
*ppvOut
)
983 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
986 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumGUID
))
988 *ppvOut
= &This
->IEnumGUID_iface
;
993 IEnumGUID_AddRef(iface
);
997 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
998 return E_NOINTERFACE
;
1001 static ULONG WINAPI
ProfilesEnumGuid_AddRef(IEnumGUID
*iface
)
1003 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1004 return InterlockedIncrement(&This
->refCount
);
1007 static ULONG WINAPI
ProfilesEnumGuid_Release(IEnumGUID
*iface
)
1009 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1012 ret
= InterlockedDecrement(&This
->refCount
);
1014 ProfilesEnumGuid_Destructor(This
);
1018 /*****************************************************
1019 * IEnumGuid functions
1020 *****************************************************/
1021 static HRESULT WINAPI
ProfilesEnumGuid_Next( LPENUMGUID iface
,
1022 ULONG celt
, GUID
*rgelt
, ULONG
*pceltFetched
)
1024 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1027 TRACE("(%p)\n",This
);
1029 if (rgelt
== NULL
) return E_POINTER
;
1031 if (This
->key
) while (fetched
< celt
)
1038 res
= RegEnumKeyExW(This
->key
, This
->next_index
, catid
, &cName
,
1039 NULL
, NULL
, NULL
, NULL
);
1040 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1041 ++(This
->next_index
);
1043 hr
= CLSIDFromString(catid
, rgelt
);
1044 if (FAILED(hr
)) continue;
1050 if (pceltFetched
) *pceltFetched
= fetched
;
1051 return fetched
== celt
? S_OK
: S_FALSE
;
1054 static HRESULT WINAPI
ProfilesEnumGuid_Skip( LPENUMGUID iface
, ULONG celt
)
1056 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1057 TRACE("(%p)\n",This
);
1059 This
->next_index
+= celt
;
1063 static HRESULT WINAPI
ProfilesEnumGuid_Reset( LPENUMGUID iface
)
1065 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1066 TRACE("(%p)\n",This
);
1067 This
->next_index
= 0;
1071 static HRESULT WINAPI
ProfilesEnumGuid_Clone( LPENUMGUID iface
,
1074 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1077 TRACE("(%p)\n",This
);
1079 if (ppenum
== NULL
) return E_POINTER
;
1081 res
= ProfilesEnumGuid_Constructor(ppenum
);
1084 ProfilesEnumGuid
*new_This
= impl_from_IEnumGUID(*ppenum
);
1085 new_This
->next_index
= This
->next_index
;
1090 static const IEnumGUIDVtbl EnumGUIDVtbl
=
1092 ProfilesEnumGuid_QueryInterface
,
1093 ProfilesEnumGuid_AddRef
,
1094 ProfilesEnumGuid_Release
,
1095 ProfilesEnumGuid_Next
,
1096 ProfilesEnumGuid_Skip
,
1097 ProfilesEnumGuid_Reset
,
1098 ProfilesEnumGuid_Clone
1101 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
)
1103 ProfilesEnumGuid
*This
;
1105 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(ProfilesEnumGuid
));
1107 return E_OUTOFMEMORY
;
1109 This
->IEnumGUID_iface
.lpVtbl
= &EnumGUIDVtbl
;
1112 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1113 KEY_READ
| KEY_WRITE
, NULL
, &This
->key
, NULL
) != ERROR_SUCCESS
)
1115 HeapFree(GetProcessHeap(), 0, This
);
1119 *ppOut
= &This
->IEnumGUID_iface
;
1120 TRACE("returning %p\n", *ppOut
);
1124 /**************************************************
1125 * IEnumTfLanguageProfiles implementation
1126 **************************************************/
1127 static void EnumTfLanguageProfiles_Destructor(EnumTfLanguageProfiles
*This
)
1129 TRACE("destroying %p\n", This
);
1130 RegCloseKey(This
->tipkey
);
1132 RegCloseKey(This
->langkey
);
1133 ITfCategoryMgr_Release(This
->catmgr
);
1134 HeapFree(GetProcessHeap(),0,This
);
1137 static HRESULT WINAPI
EnumTfLanguageProfiles_QueryInterface(IEnumTfLanguageProfiles
*iface
, REFIID iid
, LPVOID
*ppvOut
)
1139 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1143 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumTfLanguageProfiles
))
1145 *ppvOut
= &This
->IEnumTfLanguageProfiles_iface
;
1150 IEnumTfLanguageProfiles_AddRef(iface
);
1154 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
1155 return E_NOINTERFACE
;
1158 static ULONG WINAPI
EnumTfLanguageProfiles_AddRef(IEnumTfLanguageProfiles
*iface
)
1160 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1161 return InterlockedIncrement(&This
->refCount
);
1164 static ULONG WINAPI
EnumTfLanguageProfiles_Release(IEnumTfLanguageProfiles
*iface
)
1166 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1169 ret
= InterlockedDecrement(&This
->refCount
);
1171 EnumTfLanguageProfiles_Destructor(This
);
1175 /*****************************************************
1176 * IEnumGuid functions
1177 *****************************************************/
1178 static INT
next_LanguageProfile(EnumTfLanguageProfiles
*This
, CLSID clsid
, TF_LANGUAGEPROFILE
*tflp
)
1182 WCHAR profileid
[39];
1186 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1188 if (This
->langkey
== NULL
)
1190 swprintf(fullkey
,ARRAY_SIZE(fullkey
),fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1191 res
= RegOpenKeyExW(This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1194 This
->langkey
= NULL
;
1197 This
->lang_index
= 0;
1199 res
= RegEnumKeyExW(This
->langkey
, This
->lang_index
, profileid
, &cName
,
1200 NULL
, NULL
, NULL
, NULL
);
1201 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
)
1203 RegCloseKey(This
->langkey
);
1204 This
->langkey
= NULL
;
1207 ++(This
->lang_index
);
1211 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
1212 &GUID_TFCAT_TIP_SPEECH
,
1213 &GUID_TFCAT_TIP_HANDWRITING
};
1214 res
= CLSIDFromString(profileid
, &profile
);
1215 if (FAILED(res
)) return 0;
1217 tflp
->clsid
= clsid
;
1218 tflp
->langid
= This
->langid
;
1219 tflp
->fActive
= get_active_textservice(&clsid
, NULL
);
1220 tflp
->guidProfile
= profile
;
1221 if (ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1222 &tflp
->catid
, tipcats
, 3) != S_OK
)
1223 ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1224 &tflp
->catid
, NULL
, 0);
1230 static HRESULT WINAPI
EnumTfLanguageProfiles_Next(IEnumTfLanguageProfiles
*iface
,
1231 ULONG ulCount
, TF_LANGUAGEPROFILE
*pProfile
, ULONG
*pcFetch
)
1233 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1236 TRACE("(%p)\n",This
);
1238 if (pProfile
== NULL
) return E_POINTER
;
1240 if (This
->tipkey
) while (fetched
< ulCount
)
1247 res
= RegEnumKeyExW(This
->tipkey
, This
->tip_index
,
1248 This
->szwCurrentClsid
, &cName
, NULL
, NULL
, NULL
, NULL
);
1249 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1250 ++(This
->tip_index
);
1251 hr
= CLSIDFromString(This
->szwCurrentClsid
, &clsid
);
1252 if (FAILED(hr
)) continue;
1254 while ( fetched
< ulCount
)
1256 INT res
= next_LanguageProfile(This
, clsid
, pProfile
);
1269 if (pcFetch
) *pcFetch
= fetched
;
1270 return fetched
== ulCount
? S_OK
: S_FALSE
;
1273 static HRESULT WINAPI
EnumTfLanguageProfiles_Skip( IEnumTfLanguageProfiles
* iface
, ULONG celt
)
1275 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1276 FIXME("STUB (%p)\n",This
);
1280 static HRESULT WINAPI
EnumTfLanguageProfiles_Reset( IEnumTfLanguageProfiles
* iface
)
1282 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1283 TRACE("(%p)\n",This
);
1284 This
->tip_index
= 0;
1286 RegCloseKey(This
->langkey
);
1287 This
->langkey
= NULL
;
1288 This
->lang_index
= 0;
1292 static HRESULT WINAPI
EnumTfLanguageProfiles_Clone( IEnumTfLanguageProfiles
*iface
,
1293 IEnumTfLanguageProfiles
**ppenum
)
1295 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1296 EnumTfLanguageProfiles
*new_This
;
1299 TRACE("(%p)\n",This
);
1301 if (ppenum
== NULL
) return E_POINTER
;
1303 res
= EnumTfLanguageProfiles_Constructor(This
->langid
, &new_This
);
1306 new_This
->tip_index
= This
->tip_index
;
1307 lstrcpynW(new_This
->szwCurrentClsid
,This
->szwCurrentClsid
,39);
1312 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1314 swprintf(fullkey
,ARRAY_SIZE(fullkey
),fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1315 res
= RegOpenKeyExW(new_This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1316 new_This
->lang_index
= This
->lang_index
;
1318 *ppenum
= &new_This
->IEnumTfLanguageProfiles_iface
;
1323 static const IEnumTfLanguageProfilesVtbl EnumTfLanguageProfilesVtbl
=
1325 EnumTfLanguageProfiles_QueryInterface
,
1326 EnumTfLanguageProfiles_AddRef
,
1327 EnumTfLanguageProfiles_Release
,
1328 EnumTfLanguageProfiles_Clone
,
1329 EnumTfLanguageProfiles_Next
,
1330 EnumTfLanguageProfiles_Reset
,
1331 EnumTfLanguageProfiles_Skip
1334 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, EnumTfLanguageProfiles
**out
)
1337 EnumTfLanguageProfiles
*This
;
1339 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(EnumTfLanguageProfiles
));
1341 return E_OUTOFMEMORY
;
1343 This
->IEnumTfLanguageProfiles_iface
.lpVtbl
= &EnumTfLanguageProfilesVtbl
;
1345 This
->langid
= langid
;
1347 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&This
->catmgr
);
1350 HeapFree(GetProcessHeap(),0,This
);
1354 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1355 KEY_READ
| KEY_WRITE
, NULL
, &This
->tipkey
, NULL
) != ERROR_SUCCESS
)
1357 HeapFree(GetProcessHeap(), 0, This
);
1362 TRACE("returning %p\n", *out
);