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
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(dsquery
);
34 static HINSTANCE instance
;
36 /******************************************************************
37 * IClassFactory implementation
39 struct query_class_factory
{
40 IClassFactory IClassFactory_iface
;
42 HRESULT (*pfnCreateInstance
)(IUnknown
*outer
, REFIID riid
, void **out
);
45 static inline struct query_class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
47 return CONTAINING_RECORD(iface
, struct query_class_factory
, IClassFactory_iface
);
50 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **out
)
52 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), out
);
54 if (IsEqualGUID(riid
, &IID_IClassFactory
) || IsEqualGUID(riid
, &IID_IUnknown
))
56 IClassFactory_AddRef(iface
);
61 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
66 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
68 struct query_class_factory
*This
= impl_from_IClassFactory(iface
);
69 ULONG ref
= InterlockedIncrement(&This
->ref
);
71 TRACE("(%p) increasing refcount to %u\n", iface
, ref
);
76 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
78 struct query_class_factory
*This
= impl_from_IClassFactory(iface
);
79 ULONG ref
= InterlockedDecrement(&This
->ref
);
81 TRACE("(%p) decreasing refcount to %u\n", iface
, ref
);
84 HeapFree(GetProcessHeap(), 0, This
);
89 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
,
90 IUnknown
*outer
, REFIID riid
, void **out
)
92 struct query_class_factory
*This
= impl_from_IClassFactory(iface
);
94 TRACE("(%p)->(%p, %s, %p)\n", iface
, outer
, debugstr_guid(riid
), out
);
96 return This
->pfnCreateInstance(outer
, riid
, out
);
99 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
101 FIXME("(%p)->(%d)\n", iface
, dolock
);
106 static const IClassFactoryVtbl query_class_factory_vtbl
=
108 ClassFactory_QueryInterface
,
110 ClassFactory_Release
,
111 ClassFactory_CreateInstance
,
112 ClassFactory_LockServer
,
115 /******************************************************************
116 * ICommonQuery implementation
118 struct common_query
{
119 ICommonQuery ICommonQuery_iface
;
123 static inline struct common_query
*impl_from_ICommonQuery(ICommonQuery
*iface
)
125 return CONTAINING_RECORD(iface
, struct common_query
, ICommonQuery_iface
);
128 static HRESULT WINAPI
CommonQuery_QueryInterface(ICommonQuery
*iface
, REFIID riid
, void **out
)
130 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), out
);
132 if (IsEqualGUID(riid
, &IID_ICommonQuery
) || IsEqualGUID(riid
, &IID_IUnknown
))
134 ICommonQuery_AddRef(iface
);
139 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
141 return E_NOINTERFACE
;
144 static ULONG WINAPI
CommonQuery_AddRef(ICommonQuery
*iface
)
146 struct common_query
*This
= impl_from_ICommonQuery(iface
);
147 ULONG ref
= InterlockedIncrement(&This
->ref
);
149 TRACE("(%p) increasing refcount to %u\n", iface
, ref
);
154 static ULONG WINAPI
CommonQuery_Release(ICommonQuery
*iface
)
156 struct common_query
*This
= impl_from_ICommonQuery(iface
);
157 ULONG ref
= InterlockedDecrement(&This
->ref
);
159 TRACE("(%p) decreasing refcount to %u\n", iface
, ref
);
162 HeapFree(GetProcessHeap(), 0, This
);
167 static HRESULT WINAPI
CommonQuery_OpenQueryWindow(ICommonQuery
*iface
,
168 HWND parent
, LPOPENQUERYWINDOW query_window
, IDataObject
**data_object
)
170 FIXME("(%p)->(%p, %p, %p) stub!\n", iface
, parent
, query_window
, data_object
);
175 static const ICommonQueryVtbl CommonQuery_vtbl
=
177 CommonQuery_QueryInterface
,
180 CommonQuery_OpenQueryWindow
,
183 static HRESULT
CommonQuery_create(IUnknown
*outer
, REFIID riid
, void **out
)
185 struct common_query
*query
;
187 TRACE("outer %p, riid %s, out %p\n", outer
, debugstr_guid(riid
), out
);
190 return CLASS_E_NOAGGREGATION
;
192 if (!(query
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*query
))))
193 return E_OUTOFMEMORY
;
195 query
->ICommonQuery_iface
.lpVtbl
= &CommonQuery_vtbl
;
196 return ICommonQuery_QueryInterface(&query
->ICommonQuery_iface
, riid
, out
);
199 /***********************************************************************
202 BOOL WINAPI
DllMain(HINSTANCE inst
, DWORD reason
, void *reserved
)
204 TRACE("(%p, %u, %p)\n", inst
, reason
, reserved
);
208 case DLL_PROCESS_ATTACH
:
210 DisableThreadLibraryCalls(inst
);
217 /***********************************************************************
218 * DllCanUnloadNow (DSQUERY.@)
220 HRESULT WINAPI
DllCanUnloadNow(void)
225 /***********************************************************************
226 * DllGetClassObject (DSQUERY.@)
228 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **out
)
230 TRACE("rclsid %s, riid %s, out %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), out
);
232 if (!IsEqualGUID( &IID_IClassFactory
, riid
)
233 && !IsEqualGUID( &IID_IUnknown
, riid
))
235 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
237 return E_NOINTERFACE
;
240 if (IsEqualGUID(&CLSID_CommonQuery
, rclsid
))
242 struct query_class_factory
*factory
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*factory
));
243 if (!factory
) return E_OUTOFMEMORY
;
245 factory
->IClassFactory_iface
.lpVtbl
= &query_class_factory_vtbl
;
247 factory
->pfnCreateInstance
= CommonQuery_create
;
252 FIXME("%s: no class found\n", debugstr_guid(rclsid
));
254 return CLASS_E_CLASSNOTAVAILABLE
;
257 /***********************************************************************
258 * DllRegisterServer (DSQUERY.@)
260 HRESULT WINAPI
DllRegisterServer(void)
262 return __wine_register_resources( instance
);
265 /***********************************************************************
266 * DllUnregisterServer (DSQUERY.@)
268 HRESULT WINAPI
DllUnregisterServer(void)
270 return __wine_unregister_resources( instance
);