[MSCTF]
[reactos.git] / reactos / dll / win32 / msctf / displayattributemgr.c
1 /*
2 * ITfDisplayAttributeMgr implementation
3 *
4 * Copyright 2010 CodeWeavers, Aric Stewart
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include "msctf_internal.h"
22
23 typedef struct tagDisplayAttributeMgr {
24 ITfDisplayAttributeMgr ITfDisplayAttributeMgr_iface;
25
26 LONG refCount;
27
28 } DisplayAttributeMgr;
29
30 static inline DisplayAttributeMgr *impl_from_ITfDisplayAttributeMgr(ITfDisplayAttributeMgr *iface)
31 {
32 return CONTAINING_RECORD(iface, DisplayAttributeMgr, ITfDisplayAttributeMgr_iface);
33 }
34
35 static void DisplayAttributeMgr_Destructor(DisplayAttributeMgr *This)
36 {
37 TRACE("destroying %p\n", This);
38
39 HeapFree(GetProcessHeap(),0,This);
40 }
41
42 static HRESULT WINAPI DisplayAttributeMgr_QueryInterface(ITfDisplayAttributeMgr *iface, REFIID iid, LPVOID *ppvOut)
43 {
44 DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
45 *ppvOut = NULL;
46
47 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfDisplayAttributeMgr))
48 {
49 *ppvOut = This;
50 }
51
52 if (*ppvOut)
53 {
54 ITfDisplayAttributeMgr_AddRef(iface);
55 return S_OK;
56 }
57
58 WARN("unsupported interface: %s\n", debugstr_guid(iid));
59 return E_NOINTERFACE;
60 }
61
62 static ULONG WINAPI DisplayAttributeMgr_AddRef(ITfDisplayAttributeMgr *iface)
63 {
64 DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
65 return InterlockedIncrement(&This->refCount);
66 }
67
68 static ULONG WINAPI DisplayAttributeMgr_Release(ITfDisplayAttributeMgr *iface)
69 {
70 DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
71 ULONG ret;
72
73 ret = InterlockedDecrement(&This->refCount);
74 if (ret == 0)
75 DisplayAttributeMgr_Destructor(This);
76 return ret;
77 }
78
79 /*****************************************************
80 * ITfDisplayAttributeMgr functions
81 *****************************************************/
82
83 static HRESULT WINAPI DisplayAttributeMgr_OnUpdateInfo(ITfDisplayAttributeMgr *iface)
84 {
85 DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
86
87 FIXME("STUB:(%p)\n",This);
88 return E_NOTIMPL;
89 }
90
91 static HRESULT WINAPI DisplayAttributeMgr_EnumDisplayAttributeInfo(ITfDisplayAttributeMgr *iface, IEnumTfDisplayAttributeInfo **ppEnum)
92 {
93 DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
94
95 FIXME("STUB:(%p)\n",This);
96 return E_NOTIMPL;
97 }
98
99 static HRESULT WINAPI DisplayAttributeMgr_GetDisplayAttributeInfo(ITfDisplayAttributeMgr *iface, REFGUID guid, ITfDisplayAttributeInfo **ppInfo, CLSID *pclsidOwner)
100 {
101 DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
102
103 FIXME("STUB:(%p)\n",This);
104 return E_NOTIMPL;
105 }
106
107 static const ITfDisplayAttributeMgrVtbl DisplayAttributeMgr_DisplayAttributeMgrVtbl =
108 {
109 DisplayAttributeMgr_QueryInterface,
110 DisplayAttributeMgr_AddRef,
111 DisplayAttributeMgr_Release,
112
113 DisplayAttributeMgr_OnUpdateInfo,
114 DisplayAttributeMgr_EnumDisplayAttributeInfo,
115 DisplayAttributeMgr_GetDisplayAttributeInfo
116 };
117
118 HRESULT DisplayAttributeMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
119 {
120 DisplayAttributeMgr *This;
121 if (pUnkOuter)
122 return CLASS_E_NOAGGREGATION;
123
124 This = HeapAlloc(GetProcessHeap(),0,sizeof(DisplayAttributeMgr));
125 if (This == NULL)
126 return E_OUTOFMEMORY;
127
128 This->ITfDisplayAttributeMgr_iface.lpVtbl = &DisplayAttributeMgr_DisplayAttributeMgrVtbl;
129 This->refCount = 1;
130
131 TRACE("returning %p\n", This);
132 *ppOut = (IUnknown *)This;
133 return S_OK;
134 }