[MSCMS] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / msctf / langbarmgr.c
1 /*
2 * ITfLangBarMgr implementation
3 *
4 * Copyright 2010 Justin Chevrier
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 tagLangBarMgr {
24 ITfLangBarMgr ITfLangBarMgr_iface;
25
26 LONG refCount;
27
28 } LangBarMgr;
29
30 static inline LangBarMgr *impl_from_ITfLangBarMgr(ITfLangBarMgr *iface)
31 {
32 return CONTAINING_RECORD(iface, LangBarMgr, ITfLangBarMgr_iface);
33 }
34
35 static void LangBarMgr_Destructor(LangBarMgr *This)
36 {
37 TRACE("destroying %p\n", This);
38
39 HeapFree(GetProcessHeap(),0,This);
40 }
41
42 static HRESULT WINAPI LangBarMgr_QueryInterface(ITfLangBarMgr *iface, REFIID iid, LPVOID *ppvOut)
43 {
44 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
45 *ppvOut = NULL;
46
47 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfLangBarMgr))
48 {
49 *ppvOut = &This->ITfLangBarMgr_iface;
50 }
51
52 if (*ppvOut)
53 {
54 ITfLangBarMgr_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 LangBarMgr_AddRef(ITfLangBarMgr *iface)
63 {
64 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
65 return InterlockedIncrement(&This->refCount);
66 }
67
68 static ULONG WINAPI LangBarMgr_Release(ITfLangBarMgr *iface)
69 {
70 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
71 ULONG ret;
72
73 ret = InterlockedDecrement(&This->refCount);
74 if (ret == 0)
75 LangBarMgr_Destructor(This);
76 return ret;
77 }
78
79 /*****************************************************
80 * ITfLangBarMgr functions
81 *****************************************************/
82
83 static HRESULT WINAPI LangBarMgr_AdviseEventSink( ITfLangBarMgr* iface, ITfLangBarEventSink *pSink, HWND hwnd, DWORD dwflags, DWORD *pdwCookie)
84 {
85 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
86
87 FIXME("STUB:(%p)\n",This);
88 return E_NOTIMPL;
89 }
90
91 static HRESULT WINAPI LangBarMgr_UnAdviseEventSink( ITfLangBarMgr* iface, DWORD dwCookie)
92 {
93 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
94
95 FIXME("STUB:(%p)\n",This);
96 return E_NOTIMPL;
97 }
98
99 static HRESULT WINAPI LangBarMgr_GetThreadMarshalInterface( ITfLangBarMgr* iface, DWORD dwThreadId, DWORD dwType, REFIID riid, IUnknown **ppunk)
100 {
101 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
102
103 FIXME("STUB:(%p)\n",This);
104 return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI LangBarMgr_GetThreadLangBarItemMgr( ITfLangBarMgr* iface, DWORD dwThreadId, ITfLangBarItemMgr **pplbi, DWORD *pdwThreadid)
108 {
109 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
110
111 FIXME("STUB:(%p)\n",This);
112 return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI LangBarMgr_GetInputProcessorProfiles( ITfLangBarMgr* iface, DWORD dwThreadId, ITfInputProcessorProfiles **ppaip, DWORD *pdwThreadid)
116 {
117 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
118
119 FIXME("STUB:(%p)\n",This);
120 return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI LangBarMgr_RestoreLastFocus( ITfLangBarMgr* iface, DWORD *dwThreadId, BOOL fPrev)
124 {
125 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
126
127 FIXME("STUB:(%p)\n",This);
128 return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI LangBarMgr_SetModalInput( ITfLangBarMgr* iface, ITfLangBarEventSink *pSink, DWORD dwThreadId, DWORD dwFlags)
132 {
133 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
134
135 FIXME("STUB:(%p)\n",This);
136 return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI LangBarMgr_ShowFloating( ITfLangBarMgr* iface, DWORD dwFlags)
140 {
141 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
142
143 FIXME("STUB:(%p)\n",This);
144 return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI LangBarMgr_GetShowFloatingStatus( ITfLangBarMgr* iface, DWORD *pdwFlags)
148 {
149 LangBarMgr *This = impl_from_ITfLangBarMgr(iface);
150
151 FIXME("STUB:(%p)\n",This);
152 return E_NOTIMPL;
153 }
154
155 static const ITfLangBarMgrVtbl LangBarMgr_LangBarMgrVtbl =
156 {
157 LangBarMgr_QueryInterface,
158 LangBarMgr_AddRef,
159 LangBarMgr_Release,
160
161 LangBarMgr_AdviseEventSink,
162 LangBarMgr_UnAdviseEventSink,
163 LangBarMgr_GetThreadMarshalInterface,
164 LangBarMgr_GetThreadLangBarItemMgr,
165 LangBarMgr_GetInputProcessorProfiles,
166 LangBarMgr_RestoreLastFocus,
167 LangBarMgr_SetModalInput,
168 LangBarMgr_ShowFloating,
169 LangBarMgr_GetShowFloatingStatus
170 };
171
172 HRESULT LangBarMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
173 {
174 LangBarMgr *This;
175 if (pUnkOuter)
176 return CLASS_E_NOAGGREGATION;
177
178 This = HeapAlloc(GetProcessHeap(),0,sizeof(LangBarMgr));
179 if (This == NULL)
180 return E_OUTOFMEMORY;
181
182 This->ITfLangBarMgr_iface.lpVtbl = &LangBarMgr_LangBarMgrVtbl;
183 This->refCount = 1;
184
185 *ppOut = (IUnknown *)&This->ITfLangBarMgr_iface;
186 TRACE("returning %p\n", *ppOut);
187 return S_OK;
188 }