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 /******************************************************************
35 * IClassFactory implementation
37 struct query_class_factory
{
38 IClassFactory IClassFactory_iface
;
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
);
59 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
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
);
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
);
82 HeapFree(GetProcessHeap(), 0, This
);
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
);
104 static const IClassFactoryVtbl query_class_factory_vtbl
=
106 ClassFactory_QueryInterface
,
108 ClassFactory_Release
,
109 ClassFactory_CreateInstance
,
110 ClassFactory_LockServer
,
113 /******************************************************************
114 * ICommonQuery implementation
116 struct common_query
{
117 ICommonQuery ICommonQuery_iface
;
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
);
137 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
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
);
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
);
160 HeapFree(GetProcessHeap(), 0, This
);
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
);
173 static const ICommonQueryVtbl CommonQuery_vtbl
=
175 CommonQuery_QueryInterface
,
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
);
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
));
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
;
219 factory
->pfnCreateInstance
= CommonQuery_create
;
224 FIXME("%s: no class found\n", debugstr_guid(rclsid
));
226 return CLASS_E_CLASSNOTAVAILABLE
;