ddraw: Allow the ddraw RGB device to be enumerated in IDirect3D3::FindDevice.
[wine] / dlls / wuapi / searcher.c
1 /*
2  * IUpdateSearcher implementation
3  *
4  * Copyright 2008 Hans Leidekker
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #define COBJMACROS
22
23 #include "config.h"
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "wuapi.h"
31
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
35
36 typedef struct _update_searcher
37 {
38     const struct IUpdateSearcherVtbl *vtbl;
39     LONG refs;
40 } update_searcher;
41
42 static inline update_searcher *impl_from_IUpdateSearcher( IUpdateSearcher *iface )
43 {
44     return (update_searcher *)((char *)iface - FIELD_OFFSET( update_searcher, vtbl ));
45 }
46
47 static ULONG WINAPI update_searcher_AddRef(
48     IUpdateSearcher *iface )
49 {
50     update_searcher *update_searcher = impl_from_IUpdateSearcher( iface );
51     return InterlockedIncrement( &update_searcher->refs );
52 }
53
54 static ULONG WINAPI update_searcher_Release(
55     IUpdateSearcher *iface )
56 {
57     update_searcher *update_searcher = impl_from_IUpdateSearcher( iface );
58     LONG refs = InterlockedDecrement( &update_searcher->refs );
59     if (!refs)
60     {
61         TRACE("destroying %p\n", update_searcher);
62         HeapFree( GetProcessHeap(), 0, update_searcher );
63     }
64     return refs;
65 }
66
67 static HRESULT WINAPI update_searcher_QueryInterface(
68     IUpdateSearcher *iface,
69     REFIID riid,
70     void **ppvObject )
71 {
72     update_searcher *This = impl_from_IUpdateSearcher( iface );
73
74     TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
75
76     if ( IsEqualGUID( riid, &IID_IUpdateSearcher ) ||
77          IsEqualGUID( riid, &IID_IDispatch ) ||
78          IsEqualGUID( riid, &IID_IUnknown ) )
79     {
80         *ppvObject = iface;
81     }
82     else
83     {
84         FIXME("interface %s not implemented\n", debugstr_guid(riid));
85         return E_NOINTERFACE;
86     }
87     IUpdateSearcher_AddRef( iface );
88     return S_OK;
89 }
90
91 static HRESULT WINAPI update_searcher_GetTypeInfoCount(
92     IUpdateSearcher *iface,
93     UINT *pctinfo )
94 {
95     FIXME("\n");
96     return E_NOTIMPL;
97 }
98
99 static HRESULT WINAPI update_searcher_GetTypeInfo(
100     IUpdateSearcher *iface,
101     UINT iTInfo,
102     LCID lcid,
103     ITypeInfo **ppTInfo )
104 {
105     FIXME("\n");
106     return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI update_searcher_GetIDsOfNames(
110     IUpdateSearcher *iface,
111     REFIID riid,
112     LPOLESTR *rgszNames,
113     UINT cNames,
114     LCID lcid,
115     DISPID *rgDispId )
116 {
117     FIXME("\n");
118     return E_NOTIMPL;
119 }
120
121 static HRESULT WINAPI update_searcher_Invoke(
122     IUpdateSearcher *iface,
123     DISPID dispIdMember,
124     REFIID riid,
125     LCID lcid,
126     WORD wFlags,
127     DISPPARAMS *pDispParams,
128     VARIANT *pVarResult,
129     EXCEPINFO *pExcepInfo,
130     UINT *puArgErr )
131 {
132     FIXME("\n");
133     return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI update_searcher_get_CanAutomaticallyUpgradeService(
137     IUpdateSearcher *This,
138     VARIANT_BOOL *retval )
139 {
140     FIXME("\n");
141     return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI update_searcher_put_CanAutomaticallyUpgradeService(
145     IUpdateSearcher *This,
146     VARIANT_BOOL value )
147 {
148     FIXME("%p, %d\n", This, value);
149     return S_OK;
150 }
151
152 static HRESULT WINAPI update_searcher_get_ClientApplicationID(
153     IUpdateSearcher *This,
154     BSTR *retval )
155 {
156     FIXME("\n");
157     return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI update_searcher_put_ClientApplicationID(
161     IUpdateSearcher *This,
162     BSTR value )
163 {
164     FIXME("%p, %s\n", This, debugstr_w(value));
165     return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI update_searcher_get_IncludePotentiallySupersededUpdates(
169     IUpdateSearcher *This,
170     VARIANT_BOOL *retval )
171 {
172     FIXME("\n");
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI update_searcher_put_IncludePotentiallySupersededUpdates(
177     IUpdateSearcher *This,
178     VARIANT_BOOL value )
179 {
180     FIXME("\n");
181     return E_NOTIMPL;
182 }
183
184 static HRESULT WINAPI update_searcher_get_ServerSelection(
185     IUpdateSearcher *This,
186     ServerSelection *retval )
187 {
188     FIXME("\n");
189     return E_NOTIMPL;
190 }
191
192 static HRESULT WINAPI update_searcher_put_ServerSelection(
193     IUpdateSearcher *This,
194     ServerSelection value )
195 {
196     FIXME("\n");
197     return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI update_searcher_BeginSearch(
201     IUpdateSearcher *This,
202     BSTR criteria,
203     IUnknown *onCompleted,
204     VARIANT state,
205     ISearchJob **retval )
206 {
207     FIXME("\n");
208     return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI update_searcher_EndSearch(
212     IUpdateSearcher *This,
213     ISearchJob *searchJob,
214     ISearchResult **retval )
215 {
216     FIXME("\n");
217     return E_NOTIMPL;
218 }
219
220 static const struct IUpdateSearcherVtbl update_searcher_vtbl =
221 {
222     update_searcher_QueryInterface,
223     update_searcher_AddRef,
224     update_searcher_Release,
225     update_searcher_GetTypeInfoCount,
226     update_searcher_GetTypeInfo,
227     update_searcher_GetIDsOfNames,
228     update_searcher_Invoke,
229     update_searcher_get_CanAutomaticallyUpgradeService,
230     update_searcher_put_CanAutomaticallyUpgradeService,
231     update_searcher_get_ClientApplicationID,
232     update_searcher_put_ClientApplicationID,
233     update_searcher_get_IncludePotentiallySupersededUpdates,
234     update_searcher_put_IncludePotentiallySupersededUpdates,
235     update_searcher_get_ServerSelection,
236     update_searcher_put_ServerSelection,
237     update_searcher_BeginSearch,
238     update_searcher_EndSearch
239 };
240
241 HRESULT UpdateSearcher_create( IUnknown *pUnkOuter, LPVOID *ppObj )
242 {
243     update_searcher *searcher;
244
245     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
246
247     searcher = HeapAlloc( GetProcessHeap(), 0, sizeof(*searcher) );
248     if (!searcher) return E_OUTOFMEMORY;
249
250     searcher->vtbl = &update_searcher_vtbl;
251     searcher->refs = 1;
252
253     *ppObj = &searcher->vtbl;
254
255     TRACE("returning iface %p\n", *ppObj);
256     return S_OK;
257 }