widl: Add support for protected attribute.
[wine.git] / dlls / dsquery / main.c
blob06fe1e6e5f573e03045785b132504c47c0a528c4
1 /*
2 * Copyright 2017 Zebediah Figura for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "objbase.h"
27 #include "rpcproxy.h"
28 #include "initguid.h"
29 #include "cmnquery.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(dsquery);
34 /******************************************************************
35 * IClassFactory implementation
37 struct query_class_factory {
38 IClassFactory IClassFactory_iface;
39 LONG ref;
40 HRESULT (*pfnCreateInstance)(IUnknown *outer, REFIID riid, void **out);
43 static inline struct query_class_factory *impl_from_IClassFactory(IClassFactory *iface)
45 return CONTAINING_RECORD(iface, struct query_class_factory, IClassFactory_iface);
48 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **out)
50 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), out);
52 if (IsEqualGUID(riid, &IID_IClassFactory) || IsEqualGUID(riid, &IID_IUnknown))
54 IClassFactory_AddRef(iface);
55 *out = iface;
56 return S_OK;
59 FIXME("interface %s not implemented\n", debugstr_guid(riid));
60 *out = NULL;
61 return E_NOINTERFACE;
64 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
66 struct query_class_factory *This = impl_from_IClassFactory(iface);
67 ULONG ref = InterlockedIncrement(&This->ref);
69 TRACE("(%p) increasing refcount to %lu\n", iface, ref);
71 return ref;
74 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
76 struct query_class_factory *This = impl_from_IClassFactory(iface);
77 ULONG ref = InterlockedDecrement(&This->ref);
79 TRACE("(%p) decreasing refcount to %lu\n", iface, ref);
81 if (ref == 0)
82 HeapFree(GetProcessHeap(), 0, This);
84 return ref;
87 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface,
88 IUnknown *outer, REFIID riid, void **out)
90 struct query_class_factory *This = impl_from_IClassFactory(iface);
92 TRACE("(%p)->(%p, %s, %p)\n", iface, outer, debugstr_guid(riid), out);
94 return This->pfnCreateInstance(outer, riid, out);
97 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
99 FIXME("(%p)->(%d)\n", iface, dolock);
101 return S_OK;
104 static const IClassFactoryVtbl query_class_factory_vtbl =
106 ClassFactory_QueryInterface,
107 ClassFactory_AddRef,
108 ClassFactory_Release,
109 ClassFactory_CreateInstance,
110 ClassFactory_LockServer,
113 /******************************************************************
114 * ICommonQuery implementation
116 struct common_query {
117 ICommonQuery ICommonQuery_iface;
118 LONG ref;
121 static inline struct common_query *impl_from_ICommonQuery(ICommonQuery *iface)
123 return CONTAINING_RECORD(iface, struct common_query, ICommonQuery_iface);
126 static HRESULT WINAPI CommonQuery_QueryInterface(ICommonQuery *iface, REFIID riid, void **out)
128 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), out);
130 if (IsEqualGUID(riid, &IID_ICommonQuery) || IsEqualGUID(riid, &IID_IUnknown))
132 ICommonQuery_AddRef(iface);
133 *out = iface;
134 return S_OK;
137 FIXME("interface %s not implemented\n", debugstr_guid(riid));
138 *out = NULL;
139 return E_NOINTERFACE;
142 static ULONG WINAPI CommonQuery_AddRef(ICommonQuery *iface)
144 struct common_query *This = impl_from_ICommonQuery(iface);
145 ULONG ref = InterlockedIncrement(&This->ref);
147 TRACE("(%p) increasing refcount to %lu\n", iface, ref);
149 return ref;
152 static ULONG WINAPI CommonQuery_Release(ICommonQuery *iface)
154 struct common_query *This = impl_from_ICommonQuery(iface);
155 ULONG ref = InterlockedDecrement(&This->ref);
157 TRACE("(%p) decreasing refcount to %lu\n", iface, ref);
159 if (ref == 0)
160 HeapFree(GetProcessHeap(), 0, This);
162 return ref;
165 static HRESULT WINAPI CommonQuery_OpenQueryWindow(ICommonQuery *iface,
166 HWND parent, LPOPENQUERYWINDOW query_window, IDataObject **data_object)
168 FIXME("(%p)->(%p, %p, %p) stub!\n", iface, parent, query_window, data_object);
170 return E_NOTIMPL;
173 static const ICommonQueryVtbl CommonQuery_vtbl =
175 CommonQuery_QueryInterface,
176 CommonQuery_AddRef,
177 CommonQuery_Release,
178 CommonQuery_OpenQueryWindow,
181 static HRESULT CommonQuery_create(IUnknown *outer, REFIID riid, void **out)
183 struct common_query *query;
185 TRACE("outer %p, riid %s, out %p\n", outer, debugstr_guid(riid), out);
187 if (outer)
188 return CLASS_E_NOAGGREGATION;
190 if (!(query = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*query))))
191 return E_OUTOFMEMORY;
193 query->ICommonQuery_iface.lpVtbl = &CommonQuery_vtbl;
194 return ICommonQuery_QueryInterface(&query->ICommonQuery_iface, riid, out);
197 /***********************************************************************
198 * DllGetClassObject (DSQUERY.@)
200 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **out)
202 TRACE("rclsid %s, riid %s, out %p\n", debugstr_guid(rclsid), debugstr_guid(riid), out);
204 if (!IsEqualGUID( &IID_IClassFactory, riid)
205 && !IsEqualGUID( &IID_IUnknown, riid))
207 FIXME("interface %s not implemented\n", debugstr_guid(riid));
208 *out = NULL;
209 return E_NOINTERFACE;
212 if (IsEqualGUID(&CLSID_CommonQuery, rclsid))
214 struct query_class_factory *factory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*factory));
215 if (!factory) return E_OUTOFMEMORY;
217 factory->IClassFactory_iface.lpVtbl = &query_class_factory_vtbl;
218 factory->ref = 1;
219 factory->pfnCreateInstance = CommonQuery_create;
220 *out = factory;
221 return S_OK;
224 FIXME("%s: no class found\n", debugstr_guid(rclsid));
225 *out = NULL;
226 return CLASS_E_CLASSNOTAVAILABLE;