2 * ITfCompartmentMgr 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"
37 #include "wine/unicode.h"
38 #include "wine/list.h"
41 #include "msctf_internal.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
45 typedef struct tagCompartmentValue {
49 ITfCompartment *compartment;
52 typedef struct tagCompartmentMgr {
53 const ITfCompartmentMgrVtbl *CompartmentMgrVtbl;
62 HRESULT CompartmentMgr_Destructor(ITfCompartmentMgr *iface)
64 CompartmentMgr *This = (CompartmentMgr *)iface;
65 struct list *cursor, *cursor2;
67 LIST_FOR_EACH_SAFE(cursor, cursor2, &This->values)
69 CompartmentValue* value = LIST_ENTRY(cursor,CompartmentValue,entry);
71 ITfCompartment_Release(value->compartment);
72 HeapFree(GetProcessHeap(),0,value);
75 HeapFree(GetProcessHeap(),0,This);
79 /*****************************************************
80 * ITfCompartmentMgr functions
81 *****************************************************/
82 static HRESULT WINAPI CompartmentMgr_QueryInterface(ITfCompartmentMgr *iface, REFIID iid, LPVOID *ppvOut)
84 CompartmentMgr *This = (CompartmentMgr *)iface;
86 return IUnknown_QueryInterface(This->pUnkOuter, iid, *ppvOut);
91 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfCompartmentMgr))
98 IUnknown_AddRef(iface);
102 WARN("unsupported interface: %s\n", debugstr_guid(iid));
103 return E_NOINTERFACE;
107 static ULONG WINAPI CompartmentMgr_AddRef(ITfCompartmentMgr *iface)
109 CompartmentMgr *This = (CompartmentMgr *)iface;
111 return IUnknown_AddRef(This->pUnkOuter);
113 return InterlockedIncrement(&This->refCount);
116 static ULONG WINAPI CompartmentMgr_Release(ITfCompartmentMgr *iface)
118 CompartmentMgr *This = (CompartmentMgr *)iface;
120 return IUnknown_Release(This->pUnkOuter);
125 ret = InterlockedDecrement(&This->refCount);
127 CompartmentMgr_Destructor(iface);
132 static HRESULT WINAPI CompartmentMgr_GetCompartment(ITfCompartmentMgr *iface,
133 REFGUID rguid, ITfCompartment **ppcomp)
135 CompartmentMgr *This = (CompartmentMgr *)iface;
136 FIXME("STUB:(%p)\n",This);
140 static HRESULT WINAPI CompartmentMgr_ClearCompartment(ITfCompartmentMgr *iface,
141 TfClientId tid, REFGUID rguid)
143 CompartmentMgr *This = (CompartmentMgr *)iface;
144 FIXME("STUB:(%p)\n",This);
148 static HRESULT WINAPI CompartmentMgr_EnumCompartments(ITfCompartmentMgr *iface,
151 CompartmentMgr *This = (CompartmentMgr *)iface;
152 FIXME("STUB:(%p)\n",This);
156 static const ITfCompartmentMgrVtbl CompartmentMgr_CompartmentMgrVtbl =
158 CompartmentMgr_QueryInterface,
159 CompartmentMgr_AddRef,
160 CompartmentMgr_Release,
162 CompartmentMgr_GetCompartment,
163 CompartmentMgr_ClearCompartment,
164 CompartmentMgr_EnumCompartments
167 HRESULT CompartmentMgr_Constructor(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppOut)
169 CompartmentMgr *This;
174 if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
175 return CLASS_E_NOAGGREGATION;
177 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CompartmentMgr));
179 return E_OUTOFMEMORY;
181 This->CompartmentMgrVtbl = &CompartmentMgr_CompartmentMgrVtbl;
182 This->pUnkOuter = pUnkOuter;
183 list_init(&This->values);
187 TRACE("returning %p\n", This);
188 *ppOut = (IUnknown*)This;
194 hr = IUnknown_QueryInterface((IUnknown*)This, riid, (LPVOID*)ppOut);
196 HeapFree(GetProcessHeap(),0,This);