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
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(dsquery
);
35 static HINSTANCE instance
;
37 /******************************************************************
38 * IClassFactory implementation
40 struct query_class_factory
{
41 IClassFactory IClassFactory_iface
;
43 HRESULT (*pfnCreateInstance
)(IUnknown
*outer
, REFIID riid
, void **out
);
46 static inline struct query_class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
48 return CONTAINING_RECORD(iface
, struct query_class_factory
, IClassFactory_iface
);
51 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **out
)
53 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), out
);
55 if (IsEqualGUID(riid
, &IID_IClassFactory
) || IsEqualGUID(riid
, &IID_IUnknown
))
57 IClassFactory_AddRef(iface
);
62 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
67 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
69 struct query_class_factory
*This
= impl_from_IClassFactory(iface
);
70 ULONG ref
= InterlockedIncrement(&This
->ref
);
72 TRACE("(%p) increasing refcount to %u\n", iface
, ref
);
77 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
79 struct query_class_factory
*This
= impl_from_IClassFactory(iface
);
80 ULONG ref
= InterlockedDecrement(&This
->ref
);
82 TRACE("(%p) decreasing refcount to %u\n", iface
, ref
);
85 HeapFree(GetProcessHeap(), 0, This
);
90 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
,
91 IUnknown
*outer
, REFIID riid
, void **out
)
93 struct query_class_factory
*This
= impl_from_IClassFactory(iface
);
95 TRACE("(%p)->(%p, %s, %p)\n", iface
, outer
, debugstr_guid(riid
), out
);
97 return This
->pfnCreateInstance(outer
, riid
, out
);
100 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
102 FIXME("(%p)->(%d)\n", iface
, dolock
);
107 static const IClassFactoryVtbl query_class_factory_vtbl
=
109 ClassFactory_QueryInterface
,
111 ClassFactory_Release
,
112 ClassFactory_CreateInstance
,
113 ClassFactory_LockServer
,
116 /******************************************************************
117 * ICommonQuery implementation
119 struct common_query
{
120 ICommonQuery ICommonQuery_iface
;
124 static inline struct common_query
*impl_from_ICommonQuery(ICommonQuery
*iface
)
126 return CONTAINING_RECORD(iface
, struct common_query
, ICommonQuery_iface
);
129 static HRESULT WINAPI
CommonQuery_QueryInterface(ICommonQuery
*iface
, REFIID riid
, void **out
)
131 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), out
);
133 if (IsEqualGUID(riid
, &IID_ICommonQuery
) || IsEqualGUID(riid
, &IID_IUnknown
))
135 ICommonQuery_AddRef(iface
);
140 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
142 return E_NOINTERFACE
;
145 static ULONG WINAPI
CommonQuery_AddRef(ICommonQuery
*iface
)
147 struct common_query
*This
= impl_from_ICommonQuery(iface
);
148 ULONG ref
= InterlockedIncrement(&This
->ref
);
150 TRACE("(%p) increasing refcount to %u\n", iface
, ref
);
155 static ULONG WINAPI
CommonQuery_Release(ICommonQuery
*iface
)
157 struct common_query
*This
= impl_from_ICommonQuery(iface
);
158 ULONG ref
= InterlockedDecrement(&This
->ref
);
160 TRACE("(%p) decreasing refcount to %u\n", iface
, ref
);
163 HeapFree(GetProcessHeap(), 0, This
);
168 static HRESULT WINAPI
CommonQuery_OpenQueryWindow(ICommonQuery
*iface
,
169 HWND parent
, LPOPENQUERYWINDOW query_window
, IDataObject
**data_object
)
171 FIXME("(%p)->(%p, %p, %p) stub!\n", iface
, parent
, query_window
, data_object
);
176 static const ICommonQueryVtbl CommonQuery_vtbl
=
178 CommonQuery_QueryInterface
,
181 CommonQuery_OpenQueryWindow
,
184 static HRESULT
CommonQuery_create(IUnknown
*outer
, REFIID riid
, void **out
)
186 struct common_query
*query
;
188 TRACE("outer %p, riid %s, out %p\n", outer
, debugstr_guid(riid
), out
);
191 return CLASS_E_NOAGGREGATION
;
193 if (!(query
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*query
))))
194 return E_OUTOFMEMORY
;
196 query
->ICommonQuery_iface
.lpVtbl
= &CommonQuery_vtbl
;
197 return ICommonQuery_QueryInterface(&query
->ICommonQuery_iface
, riid
, out
);
200 /***********************************************************************
203 BOOL WINAPI
DllMain(HINSTANCE inst
, DWORD reason
, void *reserved
)
205 TRACE("(%p, %u, %p)\n", inst
, reason
, reserved
);
209 case DLL_PROCESS_ATTACH
:
211 DisableThreadLibraryCalls(inst
);
218 /***********************************************************************
219 * DllCanUnloadNow (DSQUERY.@)
221 HRESULT WINAPI
DllCanUnloadNow(void)
226 /***********************************************************************
227 * DllGetClassObject (DSQUERY.@)
229 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **out
)
231 TRACE("rclsid %s, riid %s, out %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), out
);
233 if (!IsEqualGUID( &IID_IClassFactory
, riid
)
234 && !IsEqualGUID( &IID_IUnknown
, riid
))
236 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
238 return E_NOINTERFACE
;
241 if (IsEqualGUID(&CLSID_CommonQuery
, rclsid
))
243 struct query_class_factory
*factory
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*factory
));
244 if (!factory
) return E_OUTOFMEMORY
;
246 factory
->IClassFactory_iface
.lpVtbl
= &query_class_factory_vtbl
;
248 factory
->pfnCreateInstance
= CommonQuery_create
;
253 FIXME("%s: no class found\n", debugstr_guid(rclsid
));
255 return CLASS_E_CLASSNOTAVAILABLE
;
258 /***********************************************************************
259 * DllRegisterServer (DSQUERY.@)
261 HRESULT WINAPI
DllRegisterServer(void)
263 return __wine_register_resources( instance
);
266 /***********************************************************************
267 * DllUnregisterServer (DSQUERY.@)
269 HRESULT WINAPI
DllUnregisterServer(void)
271 return __wine_unregister_resources( instance
);