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 CategoryMgr
*This
= (CategoryMgr
*)iface
;
172 FIXME("STUB:(%p)\n",This
);
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
);
185 static HRESULT WINAPI
CategoryMgr_UnregisterGUIDDescription (
186 ITfCategoryMgr
*iface
, REFCLSID rclsid
, REFGUID rguid
)
188 CategoryMgr
*This
= (CategoryMgr
*)iface
;
189 FIXME("STUB:(%p)\n",This
);
193 static HRESULT WINAPI
CategoryMgr_GetGUIDDescription ( ITfCategoryMgr
*iface
,
194 REFGUID rguid
, BSTR
*pbstrDesc
)
196 CategoryMgr
*This
= (CategoryMgr
*)iface
;
197 FIXME("STUB:(%p)\n",This
);
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
);
209 static HRESULT WINAPI
CategoryMgr_UnregisterGUIDDWORD ( ITfCategoryMgr
*iface
,
210 REFCLSID rclsid
, REFGUID rguid
)
212 CategoryMgr
*This
= (CategoryMgr
*)iface
;
213 FIXME("STUB:(%p)\n",This
);
217 static HRESULT WINAPI
CategoryMgr_GetGUIDDWORD ( ITfCategoryMgr
*iface
,
218 REFGUID rguid
, DWORD
*pdw
)
220 CategoryMgr
*This
= (CategoryMgr
*)iface
;
221 FIXME("STUB:(%p)\n",This
);
225 static HRESULT WINAPI
CategoryMgr_RegisterGUID ( ITfCategoryMgr
*iface
,
226 REFGUID rguid
, TfGuidAtom
*pguidatom
229 CategoryMgr
*This
= (CategoryMgr
*)iface
;
230 FIXME("STUB:(%p)\n",This
);
234 static HRESULT WINAPI
CategoryMgr_GetGUID ( ITfCategoryMgr
*iface
,
235 TfGuidAtom guidatom
, GUID
*pguid
)
237 CategoryMgr
*This
= (CategoryMgr
*)iface
;
238 FIXME("STUB:(%p)\n",This
);
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
);
251 static const ITfCategoryMgrVtbl CategoryMgr_CategoryMgrVtbl
=
253 CategoryMgr_QueryInterface
,
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
,
270 CategoryMgr_IsEqualTfGuidAtom
273 HRESULT
CategoryMgr_Constructor(IUnknown
*pUnkOuter
, IUnknown
**ppOut
)
277 return CLASS_E_NOAGGREGATION
;
279 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(CategoryMgr
));
281 return E_OUTOFMEMORY
;
283 This
->CategoryMgrVtbl
= &CategoryMgr_CategoryMgrVtbl
;
286 TRACE("returning %p\n", This
);
287 *ppOut
= (IUnknown
*)This
;