push 7b30519979490489283b8c9fd6a7de5d4bea772e
[wine/hacks.git] / dlls / msctf / categorymgr.c
blob23580724286e1d2962896ab9e12cc544420815f1
1 /*
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
21 #include "config.h"
23 #include <stdarg.h>
25 #define COBJMACROS
27 #include "wine/debug.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winuser.h"
32 #include "shlwapi.h"
33 #include "winerror.h"
34 #include "objbase.h"
36 #include "wine/unicode.h"
38 #include "msctf.h"
39 #include "msctf_internal.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
43 typedef struct tagCategoryMgr {
44 const ITfCategoryMgrVtbl *CategoryMgrVtbl;
45 LONG refCount;
46 } CategoryMgr;
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;
57 *ppvOut = NULL;
59 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfCategoryMgr))
61 *ppvOut = This;
64 if (*ppvOut)
66 IUnknown_AddRef(iface);
67 return S_OK;
70 WARN("unsupported interface: %s\n", debugstr_guid(iid));
71 return E_NOINTERFACE;
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;
83 ULONG ret;
85 ret = InterlockedDecrement(&This->refCount);
86 if (ret == 0)
87 CategoryMgr_Destructor(This);
88 return ret;
91 /*****************************************************
92 * ITfCategoryMgr functions
93 *****************************************************/
95 static HRESULT WINAPI CategoryMgr_RegisterCategory ( ITfCategoryMgr *iface,
96 REFCLSID rclsid, REFGUID rcatid, REFGUID rguid)
98 WCHAR fullkey[110];
99 WCHAR buf[39];
100 WCHAR buf2[39];
101 ULONG res;
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)
117 return E_FAIL;
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);
125 RegCloseKey(catkey);
127 if (!res)
129 sprintfW(fullkey,fmt2,ctg,itm,buf2,buf);
130 res = RegCreateKeyExW(tipkey, fullkey, 0, NULL, 0, KEY_READ | KEY_WRITE,
131 NULL, &itmkey, NULL);
133 RegCloseKey(itmkey);
136 RegCloseKey(tipkey);
138 if (!res)
139 return S_OK;
140 else
141 return E_FAIL;
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);
149 return E_NOTIMPL;
152 static HRESULT WINAPI CategoryMgr_EnumCategoriesInItem ( ITfCategoryMgr *iface,
153 REFGUID rguid, IEnumGUID **ppEnum)
155 CategoryMgr *This = (CategoryMgr*)iface;
156 FIXME("STUB:(%p)\n",This);
157 return E_NOTIMPL;
160 static HRESULT WINAPI CategoryMgr_EnumItemsInCategory ( ITfCategoryMgr *iface,
161 REFGUID rcatid, IEnumGUID **ppEnum)
163 CategoryMgr *This = (CategoryMgr*)iface;
164 FIXME("STUB:(%p)\n",This);
165 return E_NOTIMPL;
168 static HRESULT WINAPI CategoryMgr_FindClosestCategory ( ITfCategoryMgr *iface,
169 REFGUID rguid, GUID *pcatid, const GUID **ppcatidList, ULONG ulCount)
171 CategoryMgr *This = (CategoryMgr*)iface;
172 FIXME("STUB:(%p)\n",This);
173 return E_NOTIMPL;
176 static HRESULT WINAPI CategoryMgr_RegisterGUIDDescription (
177 ITfCategoryMgr *iface, REFCLSID rclsid, REFGUID rguid,
178 const WCHAR *pchDesc, ULONG cch)
180 CategoryMgr *This = (CategoryMgr*)iface;
181 FIXME("STUB:(%p)\n",This);
182 return E_NOTIMPL;
185 static HRESULT WINAPI CategoryMgr_UnregisterGUIDDescription (
186 ITfCategoryMgr *iface, REFCLSID rclsid, REFGUID rguid)
188 CategoryMgr *This = (CategoryMgr*)iface;
189 FIXME("STUB:(%p)\n",This);
190 return E_NOTIMPL;
193 static HRESULT WINAPI CategoryMgr_GetGUIDDescription ( ITfCategoryMgr *iface,
194 REFGUID rguid, BSTR *pbstrDesc)
196 CategoryMgr *This = (CategoryMgr*)iface;
197 FIXME("STUB:(%p)\n",This);
198 return E_NOTIMPL;
201 static HRESULT WINAPI CategoryMgr_RegisterGUIDDWORD ( ITfCategoryMgr *iface,
202 REFCLSID rclsid, REFGUID rguid, DWORD dw)
204 CategoryMgr *This = (CategoryMgr*)iface;
205 FIXME("STUB:(%p)\n",This);
206 return E_NOTIMPL;
209 static HRESULT WINAPI CategoryMgr_UnregisterGUIDDWORD ( ITfCategoryMgr *iface,
210 REFCLSID rclsid, REFGUID rguid)
212 CategoryMgr *This = (CategoryMgr*)iface;
213 FIXME("STUB:(%p)\n",This);
214 return E_NOTIMPL;
217 static HRESULT WINAPI CategoryMgr_GetGUIDDWORD ( ITfCategoryMgr *iface,
218 REFGUID rguid, DWORD *pdw)
220 CategoryMgr *This = (CategoryMgr*)iface;
221 FIXME("STUB:(%p)\n",This);
222 return E_NOTIMPL;
225 static HRESULT WINAPI CategoryMgr_RegisterGUID ( ITfCategoryMgr *iface,
226 REFGUID rguid, TfGuidAtom *pguidatom
229 CategoryMgr *This = (CategoryMgr*)iface;
230 FIXME("STUB:(%p)\n",This);
231 return E_NOTIMPL;
234 static HRESULT WINAPI CategoryMgr_GetGUID ( ITfCategoryMgr *iface,
235 TfGuidAtom guidatom, GUID *pguid)
237 CategoryMgr *This = (CategoryMgr*)iface;
238 FIXME("STUB:(%p)\n",This);
239 return E_NOTIMPL;
242 static HRESULT WINAPI CategoryMgr_IsEqualTfGuidAtom ( ITfCategoryMgr *iface,
243 TfGuidAtom guidatom, REFGUID rguid, BOOL *pfEqual)
245 CategoryMgr *This = (CategoryMgr*)iface;
246 FIXME("STUB:(%p)\n",This);
247 return E_NOTIMPL;
251 static const ITfCategoryMgrVtbl CategoryMgr_CategoryMgrVtbl =
253 CategoryMgr_QueryInterface,
254 CategoryMgr_AddRef,
255 CategoryMgr_Release,
257 CategoryMgr_RegisterCategory,
258 CategoryMgr_UnregisterCategory,
259 CategoryMgr_EnumCategoriesInItem,
260 CategoryMgr_EnumItemsInCategory,
261 CategoryMgr_FindClosestCategory,
262 CategoryMgr_RegisterGUIDDescription,
263 CategoryMgr_UnregisterGUIDDescription,
264 CategoryMgr_GetGUIDDescription,
265 CategoryMgr_RegisterGUIDDWORD,
266 CategoryMgr_UnregisterGUIDDWORD,
267 CategoryMgr_GetGUIDDWORD,
268 CategoryMgr_RegisterGUID,
269 CategoryMgr_GetGUID,
270 CategoryMgr_IsEqualTfGuidAtom
273 HRESULT CategoryMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
275 CategoryMgr *This;
276 if (pUnkOuter)
277 return CLASS_E_NOAGGREGATION;
279 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CategoryMgr));
280 if (This == NULL)
281 return E_OUTOFMEMORY;
283 This->CategoryMgrVtbl= &CategoryMgr_CategoryMgrVtbl;
284 This->refCount = 1;
286 TRACE("returning %p\n", This);
287 *ppOut = (IUnknown *)This;
288 return S_OK;