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