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"
40 #include "msctf_internal.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msctf
);
44 static const WCHAR szwLngp
[] = {'L','a','n','g','u','a','g','e','P','r','o','f','i','l','e',0};
45 static const WCHAR szwEnable
[] = {'E','n','a','b','l','e',0};
46 static const WCHAR szwTipfmt
[] = {'%','s','\\','%','s',0};
47 static const WCHAR szwFullLangfmt
[] = {'%','s','\\','%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
49 static const WCHAR szwAssemblies
[] = {'A','s','s','e','m','b','l','i','e','s',0};
50 static const WCHAR szwDefault
[] = {'D','e','f','a','u','l','t',0};
51 static const WCHAR szwProfile
[] = {'P','r','o','f','i','l','e',0};
52 static const WCHAR szwDefaultFmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x','\\','%','s',0};
54 typedef struct tagInputProcessorProfiles
{
55 ITfInputProcessorProfiles ITfInputProcessorProfiles_iface
;
56 ITfSource ITfSource_iface
;
57 ITfInputProcessorProfileMgr ITfInputProcessorProfileMgr_iface
;
58 /* const ITfInputProcessorProfilesExVtbl *InputProcessorProfilesExVtbl; */
59 /* const ITfInputProcessorProfileSubstituteLayoutVtbl *InputProcessorProfileSubstituteLayoutVtbl; */
62 LANGID currentLanguage
;
64 struct list LanguageProfileNotifySink
;
65 } InputProcessorProfiles
;
67 typedef struct tagProfilesEnumGuid
{
68 IEnumGUID IEnumGUID_iface
;
75 typedef struct tagEnumTfLanguageProfiles
{
76 IEnumTfLanguageProfiles IEnumTfLanguageProfiles_iface
;
81 WCHAR szwCurrentClsid
[39];
87 ITfCategoryMgr
*catmgr
;
88 } EnumTfLanguageProfiles
;
91 IEnumTfInputProcessorProfiles IEnumTfInputProcessorProfiles_iface
;
93 } EnumTfInputProcessorProfiles
;
95 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
);
96 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, IEnumTfLanguageProfiles
**ppOut
);
98 static inline EnumTfInputProcessorProfiles
*impl_from_IEnumTfInputProcessorProfiles(IEnumTfInputProcessorProfiles
*iface
)
100 return CONTAINING_RECORD(iface
, EnumTfInputProcessorProfiles
, IEnumTfInputProcessorProfiles_iface
);
103 static HRESULT WINAPI
EnumTfInputProcessorProfiles_QueryInterface(IEnumTfInputProcessorProfiles
*iface
,
104 REFIID riid
, void **ppv
)
106 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
108 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
109 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
110 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
111 }else if(IsEqualGUID(riid
, &IID_IEnumTfInputProcessorProfiles
)) {
112 TRACE("(%p)->(IID_IEnumTfInputProcessorProfiles %p)\n", This
, ppv
);
113 *ppv
= &This
->IEnumTfInputProcessorProfiles_iface
;
116 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
117 return E_NOINTERFACE
;
120 IUnknown_AddRef((IUnknown
*)*ppv
);
124 static ULONG WINAPI
EnumTfInputProcessorProfiles_AddRef(IEnumTfInputProcessorProfiles
*iface
)
126 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
127 LONG ref
= InterlockedIncrement(&This
->ref
);
129 TRACE("(%p) ref=%d\n", This
, ref
);
134 static ULONG WINAPI
EnumTfInputProcessorProfiles_Release(IEnumTfInputProcessorProfiles
*iface
)
136 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
137 LONG ref
= InterlockedDecrement(&This
->ref
);
139 TRACE("(%p) ref=%d\n", This
, ref
);
142 HeapFree(GetProcessHeap(), 0, This
);
147 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Clone(IEnumTfInputProcessorProfiles
*iface
,
148 IEnumTfInputProcessorProfiles
**ret
)
150 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
151 FIXME("(%p)->(%p)\n", This
, ret
);
155 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Next(IEnumTfInputProcessorProfiles
*iface
, ULONG count
,
156 TF_INPUTPROCESSORPROFILE
*profile
, ULONG
*fetch
)
158 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
160 FIXME("(%p)->(%u %p %p)\n", This
, count
, profile
, fetch
);
167 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Reset(IEnumTfInputProcessorProfiles
*iface
)
169 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
170 FIXME("(%p)\n", This
);
174 static HRESULT WINAPI
EnumTfInputProcessorProfiles_Skip(IEnumTfInputProcessorProfiles
*iface
, ULONG count
)
176 EnumTfInputProcessorProfiles
*This
= impl_from_IEnumTfInputProcessorProfiles(iface
);
177 FIXME("(%p)->(%u)\n", This
, count
);
181 static const IEnumTfInputProcessorProfilesVtbl EnumTfInputProcessorProfilesVtbl
= {
182 EnumTfInputProcessorProfiles_QueryInterface
,
183 EnumTfInputProcessorProfiles_AddRef
,
184 EnumTfInputProcessorProfiles_Release
,
185 EnumTfInputProcessorProfiles_Clone
,
186 EnumTfInputProcessorProfiles_Next
,
187 EnumTfInputProcessorProfiles_Reset
,
188 EnumTfInputProcessorProfiles_Skip
191 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfiles(ITfInputProcessorProfiles
*iface
)
193 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfiles_iface
);
196 static inline InputProcessorProfiles
*impl_from_ITfSource(ITfSource
*iface
)
198 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfSource_iface
);
201 static inline ProfilesEnumGuid
*impl_from_IEnumGUID(IEnumGUID
*iface
)
203 return CONTAINING_RECORD(iface
, ProfilesEnumGuid
, IEnumGUID_iface
);
206 static inline EnumTfLanguageProfiles
*impl_from_IEnumTfLanguageProfiles(IEnumTfLanguageProfiles
*iface
)
208 return CONTAINING_RECORD(iface
, EnumTfLanguageProfiles
, IEnumTfLanguageProfiles_iface
);
211 static void InputProcessorProfiles_Destructor(InputProcessorProfiles
*This
)
213 TRACE("destroying %p\n", This
);
215 free_sinks(&This
->LanguageProfileNotifySink
);
216 HeapFree(GetProcessHeap(),0,This
);
219 static void add_userkey( REFCLSID rclsid
, LANGID langid
,
226 DWORD disposition
= 0;
231 StringFromGUID2(rclsid
, buf
, 39);
232 StringFromGUID2(guidProfile
, buf2
, 39);
233 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
235 res
= RegCreateKeyExW(HKEY_CURRENT_USER
,fullkey
, 0, NULL
, 0,
236 KEY_READ
| KEY_WRITE
, NULL
, &key
, &disposition
);
238 if (!res
&& disposition
== REG_CREATED_NEW_KEY
)
241 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
248 static HRESULT WINAPI
InputProcessorProfiles_QueryInterface(ITfInputProcessorProfiles
*iface
, REFIID iid
, void **ppv
)
250 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
252 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_ITfInputProcessorProfiles
))
254 *ppv
= &This
->ITfInputProcessorProfiles_iface
;
256 else if (IsEqualIID(iid
, &IID_ITfInputProcessorProfileMgr
))
258 *ppv
= &This
->ITfInputProcessorProfileMgr_iface
;
260 else if (IsEqualIID(iid
, &IID_ITfSource
))
262 *ppv
= &This
->ITfSource_iface
;
267 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
268 return E_NOINTERFACE
;
271 ITfInputProcessorProfiles_AddRef(iface
);
275 static ULONG WINAPI
InputProcessorProfiles_AddRef(ITfInputProcessorProfiles
*iface
)
277 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
278 return InterlockedIncrement(&This
->refCount
);
281 static ULONG WINAPI
InputProcessorProfiles_Release(ITfInputProcessorProfiles
*iface
)
283 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
286 ret
= InterlockedDecrement(&This
->refCount
);
288 InputProcessorProfiles_Destructor(This
);
292 /*****************************************************
293 * ITfInputProcessorProfiles functions
294 *****************************************************/
295 static HRESULT WINAPI
InputProcessorProfiles_Register(
296 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
298 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
303 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
305 StringFromGUID2(rclsid
, buf
, 39);
306 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
308 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, NULL
, 0,
309 KEY_READ
| KEY_WRITE
, NULL
, &tipkey
, NULL
) != ERROR_SUCCESS
)
317 static HRESULT WINAPI
InputProcessorProfiles_Unregister(
318 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
)
320 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
324 TRACE("(%p) %s\n",This
,debugstr_guid(rclsid
));
326 StringFromGUID2(rclsid
, buf
, 39);
327 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
329 RegDeleteTreeW(HKEY_LOCAL_MACHINE
, fullkey
);
330 RegDeleteTreeW(HKEY_CURRENT_USER
, fullkey
);
335 static HRESULT WINAPI
InputProcessorProfiles_AddLanguageProfile(
336 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
,
337 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
,
338 ULONG cchDesc
, const WCHAR
*pchIconFile
, ULONG cchFile
,
341 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
346 DWORD disposition
= 0;
348 static const WCHAR fmt2
[] = {'%','s','\\','0','x','%','0','8','x','\\','%','s',0};
349 static const WCHAR desc
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
350 static const WCHAR icnf
[] = {'I','c','o','n','F','i','l','e',0};
351 static const WCHAR icni
[] = {'I','c','o','n','I','n','d','e','x',0};
353 TRACE("(%p) %s %x %s %s %s %i\n",This
,debugstr_guid(rclsid
), langid
,
354 debugstr_guid(guidProfile
), debugstr_wn(pchDesc
,cchDesc
),
355 debugstr_wn(pchIconFile
,cchFile
),uIconIndex
);
357 StringFromGUID2(rclsid
, buf
, 39);
358 sprintfW(fullkey
,szwTipfmt
,szwSystemTIPKey
,buf
);
360 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,fullkey
, 0, KEY_READ
| KEY_WRITE
,
361 &tipkey
) != ERROR_SUCCESS
)
364 StringFromGUID2(guidProfile
, buf
, 39);
365 sprintfW(fullkey
,fmt2
,szwLngp
,langid
,buf
);
367 res
= RegCreateKeyExW(tipkey
,fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
368 NULL
, &fmtkey
, &disposition
);
373 RegSetValueExW(fmtkey
, desc
, 0, REG_SZ
, (const BYTE
*)pchDesc
, cchDesc
* sizeof(WCHAR
));
374 RegSetValueExW(fmtkey
, icnf
, 0, REG_SZ
, (const BYTE
*)pchIconFile
, cchFile
* sizeof(WCHAR
));
375 RegSetValueExW(fmtkey
, icni
, 0, REG_DWORD
, (LPBYTE
)&uIconIndex
, sizeof(DWORD
));
376 if (disposition
== REG_CREATED_NEW_KEY
)
377 RegSetValueExW(fmtkey
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&zero
, sizeof(DWORD
));
380 add_userkey(rclsid
, langid
, guidProfile
);
390 static HRESULT WINAPI
InputProcessorProfiles_RemoveLanguageProfile(
391 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
394 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
395 FIXME("STUB:(%p)\n",This
);
399 static HRESULT WINAPI
InputProcessorProfiles_EnumInputProcessorInfo(
400 ITfInputProcessorProfiles
*iface
, IEnumGUID
**ppEnum
)
402 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
403 TRACE("(%p) %p\n",This
,ppEnum
);
404 return ProfilesEnumGuid_Constructor(ppEnum
);
407 static HRESULT WINAPI
InputProcessorProfiles_GetDefaultLanguageProfile(
408 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFGUID catid
,
409 CLSID
*pclsid
, GUID
*pguidProfile
)
411 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
418 TRACE("%p) %x %s %p %p\n",This
, langid
, debugstr_guid(catid
),pclsid
,pguidProfile
);
420 if (!catid
|| !pclsid
|| !pguidProfile
)
423 StringFromGUID2(catid
, buf
, 39);
424 sprintfW(fullkey
, szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
426 if (RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
,
427 &hkey
) != ERROR_SUCCESS
)
431 res
= RegQueryValueExW(hkey
, szwDefault
, 0, NULL
, (LPBYTE
)buf
, &count
);
432 if (res
!= ERROR_SUCCESS
)
437 CLSIDFromString(buf
,pclsid
);
439 res
= RegQueryValueExW(hkey
, szwProfile
, 0, NULL
, (LPBYTE
)buf
, &count
);
440 if (res
== ERROR_SUCCESS
)
441 CLSIDFromString(buf
,pguidProfile
);
448 static HRESULT WINAPI
InputProcessorProfiles_SetDefaultLanguageProfile(
449 ITfInputProcessorProfiles
*iface
, LANGID langid
, REFCLSID rclsid
,
450 REFGUID guidProfiles
)
452 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
458 ITfCategoryMgr
*catmgr
;
459 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
460 &GUID_TFCAT_TIP_SPEECH
,
461 &GUID_TFCAT_TIP_HANDWRITING
};
463 TRACE("%p) %x %s %s\n",This
, langid
, debugstr_guid(rclsid
),debugstr_guid(guidProfiles
));
465 if (!rclsid
|| !guidProfiles
)
468 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&catmgr
);
473 if (ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
474 &catid
, tipcats
, 3) != S_OK
)
475 hr
= ITfCategoryMgr_FindClosestCategory(catmgr
, rclsid
,
477 ITfCategoryMgr_Release(catmgr
);
482 StringFromGUID2(&catid
, buf
, 39);
483 sprintfW(fullkey
, szwDefaultFmt
, szwSystemCTFKey
, szwAssemblies
, langid
, buf
);
485 if (RegCreateKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, NULL
, 0, KEY_READ
| KEY_WRITE
,
486 NULL
, &hkey
, NULL
) != ERROR_SUCCESS
)
489 StringFromGUID2(rclsid
, buf
, 39);
490 RegSetValueExW(hkey
, szwDefault
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
491 StringFromGUID2(guidProfiles
, buf
, 39);
492 RegSetValueExW(hkey
, szwProfile
, 0, REG_SZ
, (LPBYTE
)buf
, sizeof(buf
));
498 static HRESULT WINAPI
InputProcessorProfiles_ActivateLanguageProfile(
499 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
500 REFGUID guidProfiles
)
502 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
505 TF_LANGUAGEPROFILE LanguageProfile
;
507 TRACE("(%p) %s %x %s\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfiles
));
509 if (langid
!= This
->currentLanguage
) return E_INVALIDARG
;
511 if (get_active_textservice(rclsid
,NULL
))
513 TRACE("Already Active\n");
517 hr
= ITfInputProcessorProfiles_IsEnabledLanguageProfile(iface
, rclsid
,
518 langid
, guidProfiles
, &enabled
);
519 if (FAILED(hr
) || !enabled
)
521 TRACE("Not Enabled\n");
525 LanguageProfile
.clsid
= *rclsid
;
526 LanguageProfile
.langid
= langid
;
527 LanguageProfile
.guidProfile
= *guidProfiles
;
528 LanguageProfile
.fActive
= TRUE
;
530 return add_active_textservice(&LanguageProfile
);
533 static HRESULT WINAPI
InputProcessorProfiles_GetActiveLanguageProfile(
534 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID
*plangid
,
537 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
538 TF_LANGUAGEPROFILE profile
;
540 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(rclsid
),plangid
,pguidProfile
);
542 if (!rclsid
|| !plangid
|| !pguidProfile
)
545 if (get_active_textservice(rclsid
, &profile
))
547 *plangid
= profile
.langid
;
548 *pguidProfile
= profile
.guidProfile
;
553 *pguidProfile
= GUID_NULL
;
558 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageProfileDescription(
559 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
560 REFGUID guidProfile
, BSTR
*pbstrProfile
)
562 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
563 FIXME("STUB:(%p)\n",This
);
567 static HRESULT WINAPI
InputProcessorProfiles_GetCurrentLanguage(
568 ITfInputProcessorProfiles
*iface
, LANGID
*plangid
)
570 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
571 TRACE("(%p) 0x%x\n",This
,This
->currentLanguage
);
576 *plangid
= This
->currentLanguage
;
581 static HRESULT WINAPI
InputProcessorProfiles_ChangeCurrentLanguage(
582 ITfInputProcessorProfiles
*iface
, LANGID langid
)
584 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
585 ITfLanguageProfileNotifySink
*sink
;
589 FIXME("STUB:(%p)\n",This
);
591 SINK_FOR_EACH(cursor
, &This
->LanguageProfileNotifySink
, ITfLanguageProfileNotifySink
, sink
)
594 ITfLanguageProfileNotifySink_OnLanguageChange(sink
, langid
, &accept
);
599 /* TODO: On successful language change call OnLanguageChanged sink */
603 static HRESULT WINAPI
InputProcessorProfiles_GetLanguageList(
604 ITfInputProcessorProfiles
*iface
, LANGID
**ppLangId
, ULONG
*pulCount
)
606 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
607 FIXME("Semi-STUB:(%p)\n",This
);
608 *ppLangId
= CoTaskMemAlloc(sizeof(LANGID
));
609 **ppLangId
= This
->currentLanguage
;
614 static HRESULT WINAPI
InputProcessorProfiles_EnumLanguageProfiles(
615 ITfInputProcessorProfiles
*iface
, LANGID langid
,
616 IEnumTfLanguageProfiles
**ppEnum
)
618 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
619 TRACE("(%p) %x %p\n",This
,langid
,ppEnum
);
620 return EnumTfLanguageProfiles_Constructor(langid
, ppEnum
);
623 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfile(
624 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
625 REFGUID guidProfile
, BOOL fEnable
)
627 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
634 TRACE("(%p) %s %x %s %i\n",This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), fEnable
);
636 StringFromGUID2(rclsid
, buf
, 39);
637 StringFromGUID2(guidProfile
, buf2
, 39);
638 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
640 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
644 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
653 static HRESULT WINAPI
InputProcessorProfiles_IsEnabledLanguageProfile(
654 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
655 REFGUID guidProfile
, BOOL
*pfEnable
)
657 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
664 TRACE("(%p) %s, %i, %s, %p\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),pfEnable
);
669 StringFromGUID2(rclsid
, buf
, 39);
670 StringFromGUID2(guidProfile
, buf2
, 39);
671 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
673 res
= RegOpenKeyExW(HKEY_CURRENT_USER
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
677 DWORD count
= sizeof(DWORD
);
678 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
682 if (res
) /* Try Default */
684 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
688 DWORD count
= sizeof(DWORD
);
689 res
= RegQueryValueExW(key
, szwEnable
, 0, NULL
, (LPBYTE
)pfEnable
, &count
);
700 static HRESULT WINAPI
InputProcessorProfiles_EnableLanguageProfileByDefault(
701 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
702 REFGUID guidProfile
, BOOL fEnable
)
704 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
711 TRACE("(%p) %s %x %s %i\n",This
,debugstr_guid(rclsid
),langid
,debugstr_guid(guidProfile
),fEnable
);
713 StringFromGUID2(rclsid
, buf
, 39);
714 StringFromGUID2(guidProfile
, buf2
, 39);
715 sprintfW(fullkey
,szwFullLangfmt
,szwSystemTIPKey
,buf
,szwLngp
,langid
,buf2
);
717 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &key
);
721 RegSetValueExW(key
, szwEnable
, 0, REG_DWORD
, (LPBYTE
)&fEnable
, sizeof(DWORD
));
730 static HRESULT WINAPI
InputProcessorProfiles_SubstituteKeyboardLayout(
731 ITfInputProcessorProfiles
*iface
, REFCLSID rclsid
, LANGID langid
,
732 REFGUID guidProfile
, HKL hKL
)
734 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfiles(iface
);
735 FIXME("STUB:(%p)\n",This
);
739 static const ITfInputProcessorProfilesVtbl InputProcessorProfilesVtbl
=
741 InputProcessorProfiles_QueryInterface
,
742 InputProcessorProfiles_AddRef
,
743 InputProcessorProfiles_Release
,
744 InputProcessorProfiles_Register
,
745 InputProcessorProfiles_Unregister
,
746 InputProcessorProfiles_AddLanguageProfile
,
747 InputProcessorProfiles_RemoveLanguageProfile
,
748 InputProcessorProfiles_EnumInputProcessorInfo
,
749 InputProcessorProfiles_GetDefaultLanguageProfile
,
750 InputProcessorProfiles_SetDefaultLanguageProfile
,
751 InputProcessorProfiles_ActivateLanguageProfile
,
752 InputProcessorProfiles_GetActiveLanguageProfile
,
753 InputProcessorProfiles_GetLanguageProfileDescription
,
754 InputProcessorProfiles_GetCurrentLanguage
,
755 InputProcessorProfiles_ChangeCurrentLanguage
,
756 InputProcessorProfiles_GetLanguageList
,
757 InputProcessorProfiles_EnumLanguageProfiles
,
758 InputProcessorProfiles_EnableLanguageProfile
,
759 InputProcessorProfiles_IsEnabledLanguageProfile
,
760 InputProcessorProfiles_EnableLanguageProfileByDefault
,
761 InputProcessorProfiles_SubstituteKeyboardLayout
764 static inline InputProcessorProfiles
*impl_from_ITfInputProcessorProfileMgr(ITfInputProcessorProfileMgr
*iface
)
766 return CONTAINING_RECORD(iface
, InputProcessorProfiles
, ITfInputProcessorProfileMgr_iface
);
769 static HRESULT WINAPI
InputProcessorProfileMgr_QueryInterface(ITfInputProcessorProfileMgr
*iface
, REFIID riid
, void **ppv
)
771 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
772 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, riid
, ppv
);
775 static ULONG WINAPI
InputProcessorProfileMgr_AddRef(ITfInputProcessorProfileMgr
*iface
)
777 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
778 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
781 static ULONG WINAPI
InputProcessorProfileMgr_Release(ITfInputProcessorProfileMgr
*iface
)
783 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
784 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
787 static HRESULT WINAPI
InputProcessorProfileMgr_ActivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
788 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
790 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
791 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
792 debugstr_guid(guidProfile
), hkl
, dwFlags
);
796 static HRESULT WINAPI
InputProcessorProfileMgr_DeactivateProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
797 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, DWORD dwFlags
)
799 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
800 FIXME("(%p)->(%d %x %s %s %p %x)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
801 debugstr_guid(guidProfile
), hkl
, dwFlags
);
805 static HRESULT WINAPI
InputProcessorProfileMgr_GetProfile(ITfInputProcessorProfileMgr
*iface
, DWORD dwProfileType
,
806 LANGID langid
, REFCLSID clsid
, REFGUID guidProfile
, HKL hkl
, TF_INPUTPROCESSORPROFILE
*pProfile
)
808 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
809 FIXME("(%p)->(%d %x %s %s %p %p)\n", This
, dwProfileType
, langid
, debugstr_guid(clsid
),
810 debugstr_guid(guidProfile
), hkl
, pProfile
);
814 static HRESULT WINAPI
InputProcessorProfileMgr_EnumProfiles(ITfInputProcessorProfileMgr
*iface
, LANGID langid
,
815 IEnumTfInputProcessorProfiles
**ppEnum
)
817 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
818 EnumTfInputProcessorProfiles
*enum_profiles
;
820 TRACE("(%p)->(%x %p)\n", This
, langid
, ppEnum
);
822 enum_profiles
= HeapAlloc(GetProcessHeap(), 0, sizeof(*enum_profiles
));
824 return E_OUTOFMEMORY
;
826 enum_profiles
->IEnumTfInputProcessorProfiles_iface
.lpVtbl
= &EnumTfInputProcessorProfilesVtbl
;
827 enum_profiles
->ref
= 1;
829 *ppEnum
= &enum_profiles
->IEnumTfInputProcessorProfiles_iface
;
833 static HRESULT WINAPI
InputProcessorProfileMgr_ReleaseInputProcessor(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
836 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
837 FIXME("(%p)->(%s %x)\n", This
, debugstr_guid(rclsid
), dwFlags
);
841 static HRESULT WINAPI
InputProcessorProfileMgr_RegisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
842 LANGID langid
, REFGUID guidProfile
, const WCHAR
*pchDesc
, ULONG cchDesc
, const WCHAR
*pchIconFile
,
843 ULONG cchFile
, ULONG uIconIndex
, HKL hklsubstitute
, DWORD dwPreferredLayout
, BOOL bEnabledByDefault
,
846 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
847 FIXME("(%p)->(%s %x %s %s %d %s %u %u %p %x %x %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
),
848 debugstr_w(pchDesc
), cchDesc
, debugstr_w(pchIconFile
), cchFile
, uIconIndex
, hklsubstitute
, dwPreferredLayout
,
849 bEnabledByDefault
, dwFlags
);
853 static HRESULT WINAPI
InputProcessorProfileMgr_UnregisterProfile(ITfInputProcessorProfileMgr
*iface
, REFCLSID rclsid
,
854 LANGID langid
, REFGUID guidProfile
, DWORD dwFlags
)
856 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
857 FIXME("(%p)->(%s %x %s %x)\n", This
, debugstr_guid(rclsid
), langid
, debugstr_guid(guidProfile
), dwFlags
);
861 static HRESULT WINAPI
InputProcessorProfileMgr_GetActiveProfile(ITfInputProcessorProfileMgr
*iface
, REFGUID catid
,
862 TF_INPUTPROCESSORPROFILE
*pProfile
)
864 InputProcessorProfiles
*This
= impl_from_ITfInputProcessorProfileMgr(iface
);
865 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(catid
), pProfile
);
869 static const ITfInputProcessorProfileMgrVtbl InputProcessorProfileMgrVtbl
= {
870 InputProcessorProfileMgr_QueryInterface
,
871 InputProcessorProfileMgr_AddRef
,
872 InputProcessorProfileMgr_Release
,
873 InputProcessorProfileMgr_ActivateProfile
,
874 InputProcessorProfileMgr_DeactivateProfile
,
875 InputProcessorProfileMgr_GetProfile
,
876 InputProcessorProfileMgr_EnumProfiles
,
877 InputProcessorProfileMgr_ReleaseInputProcessor
,
878 InputProcessorProfileMgr_RegisterProfile
,
879 InputProcessorProfileMgr_UnregisterProfile
,
880 InputProcessorProfileMgr_GetActiveProfile
883 /*****************************************************
884 * ITfSource functions
885 *****************************************************/
886 static HRESULT WINAPI
IPPSource_QueryInterface(ITfSource
*iface
, REFIID iid
, LPVOID
*ppvOut
)
888 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
889 return ITfInputProcessorProfiles_QueryInterface(&This
->ITfInputProcessorProfiles_iface
, iid
, ppvOut
);
892 static ULONG WINAPI
IPPSource_AddRef(ITfSource
*iface
)
894 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
895 return ITfInputProcessorProfiles_AddRef(&This
->ITfInputProcessorProfiles_iface
);
898 static ULONG WINAPI
IPPSource_Release(ITfSource
*iface
)
900 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
901 return ITfInputProcessorProfiles_Release(&This
->ITfInputProcessorProfiles_iface
);
904 static HRESULT WINAPI
IPPSource_AdviseSink(ITfSource
*iface
,
905 REFIID riid
, IUnknown
*punk
, DWORD
*pdwCookie
)
907 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
909 TRACE("(%p) %s %p %p\n",This
,debugstr_guid(riid
),punk
,pdwCookie
);
911 if (!riid
|| !punk
|| !pdwCookie
)
914 if (IsEqualIID(riid
, &IID_ITfLanguageProfileNotifySink
))
915 return advise_sink(&This
->LanguageProfileNotifySink
, &IID_ITfLanguageProfileNotifySink
,
916 COOKIE_MAGIC_IPPSINK
, punk
, pdwCookie
);
918 FIXME("(%p) Unhandled Sink: %s\n",This
,debugstr_guid(riid
));
922 static HRESULT WINAPI
IPPSource_UnadviseSink(ITfSource
*iface
, DWORD pdwCookie
)
924 InputProcessorProfiles
*This
= impl_from_ITfSource(iface
);
926 TRACE("(%p) %x\n",This
,pdwCookie
);
928 if (get_Cookie_magic(pdwCookie
)!=COOKIE_MAGIC_IPPSINK
)
931 return unadvise_sink(pdwCookie
);
934 static const ITfSourceVtbl InputProcessorProfilesSourceVtbl
=
936 IPPSource_QueryInterface
,
939 IPPSource_AdviseSink
,
940 IPPSource_UnadviseSink
,
943 HRESULT
InputProcessorProfiles_Constructor(IUnknown
*pUnkOuter
, IUnknown
**ppOut
)
945 InputProcessorProfiles
*This
;
947 return CLASS_E_NOAGGREGATION
;
949 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(InputProcessorProfiles
));
951 return E_OUTOFMEMORY
;
953 This
->ITfInputProcessorProfiles_iface
.lpVtbl
= &InputProcessorProfilesVtbl
;
954 This
->ITfSource_iface
.lpVtbl
= &InputProcessorProfilesSourceVtbl
;
955 This
->ITfInputProcessorProfileMgr_iface
.lpVtbl
= &InputProcessorProfileMgrVtbl
;
957 This
->currentLanguage
= GetUserDefaultLCID();
959 list_init(&This
->LanguageProfileNotifySink
);
961 *ppOut
= (IUnknown
*)&This
->ITfInputProcessorProfiles_iface
;
962 TRACE("returning %p\n", *ppOut
);
966 /**************************************************
967 * IEnumGUID implementation for ITfInputProcessorProfiles::EnumInputProcessorInfo
968 **************************************************/
969 static void ProfilesEnumGuid_Destructor(ProfilesEnumGuid
*This
)
971 TRACE("destroying %p\n", This
);
972 RegCloseKey(This
->key
);
973 HeapFree(GetProcessHeap(),0,This
);
976 static HRESULT WINAPI
ProfilesEnumGuid_QueryInterface(IEnumGUID
*iface
, REFIID iid
, LPVOID
*ppvOut
)
978 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
981 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumGUID
))
983 *ppvOut
= &This
->IEnumGUID_iface
;
988 IEnumGUID_AddRef(iface
);
992 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
993 return E_NOINTERFACE
;
996 static ULONG WINAPI
ProfilesEnumGuid_AddRef(IEnumGUID
*iface
)
998 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
999 return InterlockedIncrement(&This
->refCount
);
1002 static ULONG WINAPI
ProfilesEnumGuid_Release(IEnumGUID
*iface
)
1004 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1007 ret
= InterlockedDecrement(&This
->refCount
);
1009 ProfilesEnumGuid_Destructor(This
);
1013 /*****************************************************
1014 * IEnumGuid functions
1015 *****************************************************/
1016 static HRESULT WINAPI
ProfilesEnumGuid_Next( LPENUMGUID iface
,
1017 ULONG celt
, GUID
*rgelt
, ULONG
*pceltFetched
)
1019 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1022 TRACE("(%p)\n",This
);
1024 if (rgelt
== NULL
) return E_POINTER
;
1026 if (This
->key
) while (fetched
< celt
)
1033 res
= RegEnumKeyExW(This
->key
, This
->next_index
, catid
, &cName
,
1034 NULL
, NULL
, NULL
, NULL
);
1035 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1036 ++(This
->next_index
);
1038 hr
= CLSIDFromString(catid
, rgelt
);
1039 if (FAILED(hr
)) continue;
1045 if (pceltFetched
) *pceltFetched
= fetched
;
1046 return fetched
== celt
? S_OK
: S_FALSE
;
1049 static HRESULT WINAPI
ProfilesEnumGuid_Skip( LPENUMGUID iface
, ULONG celt
)
1051 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1052 TRACE("(%p)\n",This
);
1054 This
->next_index
+= celt
;
1058 static HRESULT WINAPI
ProfilesEnumGuid_Reset( LPENUMGUID iface
)
1060 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1061 TRACE("(%p)\n",This
);
1062 This
->next_index
= 0;
1066 static HRESULT WINAPI
ProfilesEnumGuid_Clone( LPENUMGUID iface
,
1069 ProfilesEnumGuid
*This
= impl_from_IEnumGUID(iface
);
1072 TRACE("(%p)\n",This
);
1074 if (ppenum
== NULL
) return E_POINTER
;
1076 res
= ProfilesEnumGuid_Constructor(ppenum
);
1079 ProfilesEnumGuid
*new_This
= impl_from_IEnumGUID(*ppenum
);
1080 new_This
->next_index
= This
->next_index
;
1085 static const IEnumGUIDVtbl EnumGUIDVtbl
=
1087 ProfilesEnumGuid_QueryInterface
,
1088 ProfilesEnumGuid_AddRef
,
1089 ProfilesEnumGuid_Release
,
1090 ProfilesEnumGuid_Next
,
1091 ProfilesEnumGuid_Skip
,
1092 ProfilesEnumGuid_Reset
,
1093 ProfilesEnumGuid_Clone
1096 static HRESULT
ProfilesEnumGuid_Constructor(IEnumGUID
**ppOut
)
1098 ProfilesEnumGuid
*This
;
1100 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(ProfilesEnumGuid
));
1102 return E_OUTOFMEMORY
;
1104 This
->IEnumGUID_iface
.lpVtbl
= &EnumGUIDVtbl
;
1107 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1108 KEY_READ
| KEY_WRITE
, NULL
, &This
->key
, NULL
) != ERROR_SUCCESS
)
1110 HeapFree(GetProcessHeap(), 0, This
);
1114 *ppOut
= &This
->IEnumGUID_iface
;
1115 TRACE("returning %p\n", *ppOut
);
1119 /**************************************************
1120 * IEnumTfLanguageProfiles implementation
1121 **************************************************/
1122 static void EnumTfLanguageProfiles_Destructor(EnumTfLanguageProfiles
*This
)
1124 TRACE("destroying %p\n", This
);
1125 RegCloseKey(This
->tipkey
);
1127 RegCloseKey(This
->langkey
);
1128 ITfCategoryMgr_Release(This
->catmgr
);
1129 HeapFree(GetProcessHeap(),0,This
);
1132 static HRESULT WINAPI
EnumTfLanguageProfiles_QueryInterface(IEnumTfLanguageProfiles
*iface
, REFIID iid
, LPVOID
*ppvOut
)
1134 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1138 if (IsEqualIID(iid
, &IID_IUnknown
) || IsEqualIID(iid
, &IID_IEnumTfLanguageProfiles
))
1140 *ppvOut
= &This
->IEnumTfLanguageProfiles_iface
;
1145 IEnumTfLanguageProfiles_AddRef(iface
);
1149 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
1150 return E_NOINTERFACE
;
1153 static ULONG WINAPI
EnumTfLanguageProfiles_AddRef(IEnumTfLanguageProfiles
*iface
)
1155 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1156 return InterlockedIncrement(&This
->refCount
);
1159 static ULONG WINAPI
EnumTfLanguageProfiles_Release(IEnumTfLanguageProfiles
*iface
)
1161 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1164 ret
= InterlockedDecrement(&This
->refCount
);
1166 EnumTfLanguageProfiles_Destructor(This
);
1170 /*****************************************************
1171 * IEnumGuid functions
1172 *****************************************************/
1173 static INT
next_LanguageProfile(EnumTfLanguageProfiles
*This
, CLSID clsid
, TF_LANGUAGEPROFILE
*tflp
)
1177 WCHAR profileid
[39];
1181 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1183 if (This
->langkey
== NULL
)
1185 sprintfW(fullkey
,fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1186 res
= RegOpenKeyExW(This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1189 This
->langkey
= NULL
;
1192 This
->lang_index
= 0;
1194 res
= RegEnumKeyExW(This
->langkey
, This
->lang_index
, profileid
, &cName
,
1195 NULL
, NULL
, NULL
, NULL
);
1196 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
)
1198 RegCloseKey(This
->langkey
);
1199 This
->langkey
= NULL
;
1202 ++(This
->lang_index
);
1206 static const GUID
* tipcats
[3] = { &GUID_TFCAT_TIP_KEYBOARD
,
1207 &GUID_TFCAT_TIP_SPEECH
,
1208 &GUID_TFCAT_TIP_HANDWRITING
};
1209 res
= CLSIDFromString(profileid
, &profile
);
1210 if (FAILED(res
)) return 0;
1212 tflp
->clsid
= clsid
;
1213 tflp
->langid
= This
->langid
;
1214 tflp
->fActive
= get_active_textservice(&clsid
, NULL
);
1215 tflp
->guidProfile
= profile
;
1216 if (ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1217 &tflp
->catid
, tipcats
, 3) != S_OK
)
1218 ITfCategoryMgr_FindClosestCategory(This
->catmgr
, &clsid
,
1219 &tflp
->catid
, NULL
, 0);
1225 static HRESULT WINAPI
EnumTfLanguageProfiles_Next(IEnumTfLanguageProfiles
*iface
,
1226 ULONG ulCount
, TF_LANGUAGEPROFILE
*pProfile
, ULONG
*pcFetch
)
1228 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1231 TRACE("(%p)\n",This
);
1233 if (pProfile
== NULL
) return E_POINTER
;
1235 if (This
->tipkey
) while (fetched
< ulCount
)
1242 res
= RegEnumKeyExW(This
->tipkey
, This
->tip_index
,
1243 This
->szwCurrentClsid
, &cName
, NULL
, NULL
, NULL
, NULL
);
1244 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_MORE_DATA
) break;
1245 ++(This
->tip_index
);
1246 hr
= CLSIDFromString(This
->szwCurrentClsid
, &clsid
);
1247 if (FAILED(hr
)) continue;
1249 while ( fetched
< ulCount
)
1251 INT res
= next_LanguageProfile(This
, clsid
, pProfile
);
1264 if (pcFetch
) *pcFetch
= fetched
;
1265 return fetched
== ulCount
? S_OK
: S_FALSE
;
1268 static HRESULT WINAPI
EnumTfLanguageProfiles_Skip( IEnumTfLanguageProfiles
* iface
, ULONG celt
)
1270 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1271 FIXME("STUB (%p)\n",This
);
1275 static HRESULT WINAPI
EnumTfLanguageProfiles_Reset( IEnumTfLanguageProfiles
* iface
)
1277 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1278 TRACE("(%p)\n",This
);
1279 This
->tip_index
= 0;
1281 RegCloseKey(This
->langkey
);
1282 This
->langkey
= NULL
;
1283 This
->lang_index
= 0;
1287 static HRESULT WINAPI
EnumTfLanguageProfiles_Clone( IEnumTfLanguageProfiles
*iface
,
1288 IEnumTfLanguageProfiles
**ppenum
)
1290 EnumTfLanguageProfiles
*This
= impl_from_IEnumTfLanguageProfiles(iface
);
1293 TRACE("(%p)\n",This
);
1295 if (ppenum
== NULL
) return E_POINTER
;
1297 res
= EnumTfLanguageProfiles_Constructor(This
->langid
, ppenum
);
1300 EnumTfLanguageProfiles
*new_This
= (EnumTfLanguageProfiles
*)*ppenum
;
1301 new_This
->tip_index
= This
->tip_index
;
1302 lstrcpynW(new_This
->szwCurrentClsid
,This
->szwCurrentClsid
,39);
1307 static const WCHAR fmt
[] = {'%','s','\\','%','s','\\','0','x','%','0','8','x',0};
1309 sprintfW(fullkey
,fmt
,This
->szwCurrentClsid
,szwLngp
,This
->langid
);
1310 res
= RegOpenKeyExW(new_This
->tipkey
, fullkey
, 0, KEY_READ
| KEY_WRITE
, &This
->langkey
);
1311 new_This
->lang_index
= This
->lang_index
;
1317 static const IEnumTfLanguageProfilesVtbl EnumTfLanguageProfilesVtbl
=
1319 EnumTfLanguageProfiles_QueryInterface
,
1320 EnumTfLanguageProfiles_AddRef
,
1321 EnumTfLanguageProfiles_Release
,
1322 EnumTfLanguageProfiles_Clone
,
1323 EnumTfLanguageProfiles_Next
,
1324 EnumTfLanguageProfiles_Reset
,
1325 EnumTfLanguageProfiles_Skip
1328 static HRESULT
EnumTfLanguageProfiles_Constructor(LANGID langid
, IEnumTfLanguageProfiles
**ppOut
)
1331 EnumTfLanguageProfiles
*This
;
1333 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(EnumTfLanguageProfiles
));
1335 return E_OUTOFMEMORY
;
1337 This
->IEnumTfLanguageProfiles_iface
.lpVtbl
= &EnumTfLanguageProfilesVtbl
;
1339 This
->langid
= langid
;
1341 hr
= CategoryMgr_Constructor(NULL
,(IUnknown
**)&This
->catmgr
);
1344 HeapFree(GetProcessHeap(),0,This
);
1348 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szwSystemTIPKey
, 0, NULL
, 0,
1349 KEY_READ
| KEY_WRITE
, NULL
, &This
->tipkey
, NULL
) != ERROR_SUCCESS
)
1351 HeapFree(GetProcessHeap(), 0, This
);
1355 *ppOut
= &This
->IEnumTfLanguageProfiles_iface
;
1356 TRACE("returning %p\n", *ppOut
);