2 * ITfCategoryMgr implementation
4 * Copyright 2009 Aric Stewart, CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
36 #include "wine/unicode.h"
39 #include "msctf_internal.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
43 typedef struct tagCategoryMgr {
44 const ITfCategoryMgrVtbl *CategoryMgrVtbl;
48 static void CategoryMgr_Destructor(CategoryMgr *This)
50 TRACE("destroying %p\n", This);
51 HeapFree(GetProcessHeap(),0,This);
54 static HRESULT WINAPI CategoryMgr_QueryInterface(ITfCategoryMgr *iface, REFIID iid, LPVOID *ppvOut)
56 CategoryMgr *This = (CategoryMgr *)iface;
59 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfCategoryMgr))
66 IUnknown_AddRef(iface);
70 WARN("unsupported interface: %s\n", debugstr_guid(iid));
74 static ULONG WINAPI CategoryMgr_AddRef(ITfCategoryMgr *iface)
76 CategoryMgr *This = (CategoryMgr *)iface;
77 return InterlockedIncrement(&This->refCount);
80 static ULONG WINAPI CategoryMgr_Release(ITfCategoryMgr *iface)
82 CategoryMgr *This = (CategoryMgr *)iface;
85 ret = InterlockedDecrement(&This->refCount);
87 CategoryMgr_Destructor(This);
91 /*****************************************************
92 * ITfCategoryMgr functions
93 *****************************************************/
95 static HRESULT WINAPI CategoryMgr_RegisterCategory ( ITfCategoryMgr *iface,
96 REFCLSID rclsid, REFGUID rcatid, REFGUID rguid)
102 HKEY tipkey,catkey,itmkey;
103 CategoryMgr *This = (CategoryMgr*)iface;
105 static const WCHAR ctg[] = {'C','a','t','e','g','o','r','y',0};
106 static const WCHAR itm[] = {'I','t','e','m',0};
107 static const WCHAR fmt[] = {'%','s','\\','%','s',0};
108 static const WCHAR fmt2[] = {'%','s','\\','%','s','\\','%','s','\\','%','s',0};
110 TRACE("(%p) %s %s %s\n",This,debugstr_guid(rclsid), debugstr_guid(rcatid), debugstr_guid(rguid));
112 StringFromGUID2(rclsid, buf, 39);
113 sprintfW(fullkey,fmt,szwSystemTIPKey,buf);
115 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,fullkey, 0, KEY_READ | KEY_WRITE,
116 &tipkey ) != ERROR_SUCCESS)
119 StringFromGUID2(rcatid, buf, 39);
120 StringFromGUID2(rguid, buf2, 39);
121 sprintfW(fullkey,fmt2,ctg,ctg,buf,buf2);
123 res = RegCreateKeyExW(tipkey, fullkey, 0, NULL, 0, KEY_READ | KEY_WRITE,
124 NULL, &catkey, NULL);
129 sprintfW(fullkey,fmt2,ctg,itm,buf2,buf);
130 res = RegCreateKeyExW(tipkey, fullkey, 0, NULL, 0, KEY_READ | KEY_WRITE,
131 NULL, &itmkey, NULL);
144 static HRESULT WINAPI CategoryMgr_UnregisterCategory ( ITfCategoryMgr *iface,
145 REFCLSID rclsid, REFGUID rcatid, REFGUID rguid)
147 CategoryMgr *This = (CategoryMgr*)iface;
148 FIXME("STUB:(%p)\n",This);
152 static HRESULT WINAPI CategoryMgr_EnumCategoriesInItem ( ITfCategoryMgr *iface,
153 REFGUID rguid, IEnumGUID **ppEnum)
155 CategoryMgr *This = (CategoryMgr*)iface;
156 FIXME("STUB:(%p)\n",This);
160 static HRESULT WINAPI CategoryMgr_EnumItemsInCategory ( ITfCategoryMgr *iface,
161 REFGUID rcatid, IEnumGUID **ppEnum)
163 CategoryMgr *This = (CategoryMgr*)iface;
164 FIXME("STUB:(%p)\n",This);
168 static HRESULT WINAPI CategoryMgr_FindClosestCategory ( ITfCategoryMgr *iface,
169 REFGUID rguid, GUID *pcatid, const GUID **ppcatidList, ULONG ulCount)
171 static const WCHAR fmt[] = { '%','s','\\','%','s','\\','C','a','t','e','g','o','r','y','\\','I','t','e','m','\\','%','s',0};
176 HRESULT hr = S_FALSE;
178 CategoryMgr *This = (CategoryMgr*)iface;
180 TRACE("(%p)\n",This);
182 if (!pcatid || (ulCount && ppcatidList == NULL))
185 StringFromGUID2(rguid, buf, 39);
186 sprintfW(fullkey,fmt,szwSystemTIPKey,buf,buf);
189 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,fullkey, 0, KEY_READ, &key ) !=
202 res = RegEnumKeyExW(key, index, catid, &cName, NULL, NULL, NULL, NULL);
203 if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break;
206 hr2 = CLSIDFromString(catid, &guid);
207 if (FAILED(hr2)) continue;
213 for (j = 0; j < ulCount; j++)
214 if (IsEqualGUID(&guid, ppcatidList[j]))
234 static HRESULT WINAPI CategoryMgr_RegisterGUIDDescription (
235 ITfCategoryMgr *iface, REFCLSID rclsid, REFGUID rguid,
236 const WCHAR *pchDesc, ULONG cch)
238 CategoryMgr *This = (CategoryMgr*)iface;
239 FIXME("STUB:(%p)\n",This);
243 static HRESULT WINAPI CategoryMgr_UnregisterGUIDDescription (
244 ITfCategoryMgr *iface, REFCLSID rclsid, REFGUID rguid)
246 CategoryMgr *This = (CategoryMgr*)iface;
247 FIXME("STUB:(%p)\n",This);
251 static HRESULT WINAPI CategoryMgr_GetGUIDDescription ( ITfCategoryMgr *iface,
252 REFGUID rguid, BSTR *pbstrDesc)
254 CategoryMgr *This = (CategoryMgr*)iface;
255 FIXME("STUB:(%p)\n",This);
259 static HRESULT WINAPI CategoryMgr_RegisterGUIDDWORD ( ITfCategoryMgr *iface,
260 REFCLSID rclsid, REFGUID rguid, DWORD dw)
262 CategoryMgr *This = (CategoryMgr*)iface;
263 FIXME("STUB:(%p)\n",This);
267 static HRESULT WINAPI CategoryMgr_UnregisterGUIDDWORD ( ITfCategoryMgr *iface,
268 REFCLSID rclsid, REFGUID rguid)
270 CategoryMgr *This = (CategoryMgr*)iface;
271 FIXME("STUB:(%p)\n",This);
275 static HRESULT WINAPI CategoryMgr_GetGUIDDWORD ( ITfCategoryMgr *iface,
276 REFGUID rguid, DWORD *pdw)
278 CategoryMgr *This = (CategoryMgr*)iface;
279 FIXME("STUB:(%p)\n",This);
283 static HRESULT WINAPI CategoryMgr_RegisterGUID ( ITfCategoryMgr *iface,
284 REFGUID rguid, TfGuidAtom *pguidatom
287 CategoryMgr *This = (CategoryMgr*)iface;
288 FIXME("STUB:(%p)\n",This);
292 static HRESULT WINAPI CategoryMgr_GetGUID ( ITfCategoryMgr *iface,
293 TfGuidAtom guidatom, GUID *pguid)
295 CategoryMgr *This = (CategoryMgr*)iface;
296 FIXME("STUB:(%p)\n",This);
300 static HRESULT WINAPI CategoryMgr_IsEqualTfGuidAtom ( ITfCategoryMgr *iface,
301 TfGuidAtom guidatom, REFGUID rguid, BOOL *pfEqual)
303 CategoryMgr *This = (CategoryMgr*)iface;
304 FIXME("STUB:(%p)\n",This);
309 static const ITfCategoryMgrVtbl CategoryMgr_CategoryMgrVtbl =
311 CategoryMgr_QueryInterface,
315 CategoryMgr_RegisterCategory,
316 CategoryMgr_UnregisterCategory,
317 CategoryMgr_EnumCategoriesInItem,
318 CategoryMgr_EnumItemsInCategory,
319 CategoryMgr_FindClosestCategory,
320 CategoryMgr_RegisterGUIDDescription,
321 CategoryMgr_UnregisterGUIDDescription,
322 CategoryMgr_GetGUIDDescription,
323 CategoryMgr_RegisterGUIDDWORD,
324 CategoryMgr_UnregisterGUIDDWORD,
325 CategoryMgr_GetGUIDDWORD,
326 CategoryMgr_RegisterGUID,
328 CategoryMgr_IsEqualTfGuidAtom
331 HRESULT CategoryMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
335 return CLASS_E_NOAGGREGATION;
337 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CategoryMgr));
339 return E_OUTOFMEMORY;
341 This->CategoryMgrVtbl= &CategoryMgr_CategoryMgrVtbl;
344 TRACE("returning %p\n", This);
345 *ppOut = (IUnknown *)This;