libwine: Remove __wine_main_arg* from the public header.
[wine/zf.git] / dlls / inseng / inseng_main.c
blob631a9364e39096c13555969348bda15b9a90ca57
1 /*
2 * INSENG Implementation
4 * Copyright 2006 Mike McCormack
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.
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.
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
21 #define COBJMACROS
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "rpcproxy.h"
31 #include "initguid.h"
32 #include "inseng.h"
34 #include "wine/debug.h"
35 #include "wine/heap.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(inseng);
39 static HINSTANCE instance;
41 struct InstallEngine {
42 IInstallEngine2 IInstallEngine2_iface;
43 LONG ref;
46 static inline InstallEngine *impl_from_IInstallEngine2(IInstallEngine2 *iface)
48 return CONTAINING_RECORD(iface, InstallEngine, IInstallEngine2_iface);
51 static HRESULT WINAPI InstallEngine_QueryInterface(IInstallEngine2 *iface, REFIID riid, void **ppv)
53 InstallEngine *This = impl_from_IInstallEngine2(iface);
55 if(IsEqualGUID(&IID_IUnknown, riid)) {
56 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
57 *ppv = &This->IInstallEngine2_iface;
58 }else if(IsEqualGUID(&IID_IInstallEngine, riid)) {
59 TRACE("(%p)->(IID_IInstallEngine %p)\n", This, ppv);
60 *ppv = &This->IInstallEngine2_iface;
61 }else if(IsEqualGUID(&IID_IInstallEngine2, riid)) {
62 TRACE("(%p)->(IID_IInstallEngine2 %p)\n", This, ppv);
63 *ppv = &This->IInstallEngine2_iface;
64 }else {
65 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
66 *ppv = NULL;
67 return E_NOINTERFACE;
70 IUnknown_AddRef((IUnknown*)*ppv);
71 return S_OK;
74 static ULONG WINAPI InstallEngine_AddRef(IInstallEngine2 *iface)
76 InstallEngine *This = impl_from_IInstallEngine2(iface);
77 LONG ref = InterlockedIncrement(&This->ref);
79 TRACE("(%p) ref=%d\n", This, ref);
81 return ref;
84 static ULONG WINAPI InstallEngine_Release(IInstallEngine2 *iface)
86 InstallEngine *This = impl_from_IInstallEngine2(iface);
87 LONG ref = InterlockedDecrement(&This->ref);
89 TRACE("(%p) ref=%d\n", This, ref);
91 if(!ref)
92 heap_free(This);
94 return ref;
97 static HRESULT WINAPI InstallEngine_GetEngineStatus(IInstallEngine2 *iface, DWORD *status)
99 InstallEngine *This = impl_from_IInstallEngine2(iface);
100 FIXME("(%p)->(%p)\n", This, status);
101 return E_NOTIMPL;
104 static HRESULT WINAPI InstallEngine_SetCifFile(IInstallEngine2 *iface, const char *cab_name, const char *cif_name)
106 InstallEngine *This = impl_from_IInstallEngine2(iface);
107 FIXME("(%p)->(%s %s)\n", This, debugstr_a(cab_name), debugstr_a(cif_name));
108 return E_NOTIMPL;
111 static HRESULT WINAPI InstallEngine_DownloadComponents(IInstallEngine2 *iface, DWORD flags)
113 InstallEngine *This = impl_from_IInstallEngine2(iface);
114 FIXME("(%p)->(%x)\n", This, flags);
115 return E_NOTIMPL;
118 static HRESULT WINAPI InstallEngine_InstallComponents(IInstallEngine2 *iface, DWORD flags)
120 InstallEngine *This = impl_from_IInstallEngine2(iface);
121 FIXME("(%p)->(%x)\n", This, flags);
122 return E_NOTIMPL;
125 static HRESULT WINAPI InstallEngine_EnumInstallIDs(IInstallEngine2 *iface, UINT index, char **id)
127 InstallEngine *This = impl_from_IInstallEngine2(iface);
128 FIXME("(%p)->(%d %p)\n", This, index, id);
129 return E_NOTIMPL;
132 static HRESULT WINAPI InstallEngine_EnumDownloadIDs(IInstallEngine2 *iface, UINT index, char **id)
134 InstallEngine *This = impl_from_IInstallEngine2(iface);
135 FIXME("(%p)->(%d %p)\n", This, index, id);
136 return E_NOTIMPL;
139 static HRESULT WINAPI InstallEngine_IsComponentInstalled(IInstallEngine2 *iface, const char *id, DWORD *status)
141 InstallEngine *This = impl_from_IInstallEngine2(iface);
142 FIXME("(%p)->(%s %p)\n", This, debugstr_a(id), status);
143 return E_NOTIMPL;
146 static HRESULT WINAPI InstallEngine_RegisterInstallEngineCallback(IInstallEngine2 *iface, IInstallEngineCallback *callback)
148 InstallEngine *This = impl_from_IInstallEngine2(iface);
149 FIXME("(%p)->(%p)\n", This, callback);
150 return E_NOTIMPL;
153 static HRESULT WINAPI InstallEngine_UnregisterInstallEngineCallback(IInstallEngine2 *iface)
155 InstallEngine *This = impl_from_IInstallEngine2(iface);
156 FIXME("(%p)\n", This);
157 return E_NOTIMPL;
160 static HRESULT WINAPI InstallEngine_SetAction(IInstallEngine2 *iface, const char *id, DWORD action, DWORD priority)
162 InstallEngine *This = impl_from_IInstallEngine2(iface);
163 FIXME("(%p)->(%s %d %d)\n", This, debugstr_a(id), action, priority);
164 return E_NOTIMPL;
167 static HRESULT WINAPI InstallEngine_GetSizes(IInstallEngine2 *iface, const char *id, COMPONENT_SIZES *sizes)
169 InstallEngine *This = impl_from_IInstallEngine2(iface);
170 FIXME("(%p)->(%s %p)\n", This, debugstr_a(id), sizes);
171 return E_NOTIMPL;
174 static HRESULT WINAPI InstallEngine_LaunchExtraCommand(IInstallEngine2 *iface, const char *inf_name, const char *section)
176 InstallEngine *This = impl_from_IInstallEngine2(iface);
177 FIXME("(%p)->(%s %s)\n", This, debugstr_a(inf_name), debugstr_a(section));
178 return E_NOTIMPL;
181 static HRESULT WINAPI InstallEngine_GetDisplayName(IInstallEngine2 *iface, const char *id, const char *name)
183 InstallEngine *This = impl_from_IInstallEngine2(iface);
184 FIXME("(%p)->(%s %s)\n", This, debugstr_a(id), debugstr_a(name));
185 return E_NOTIMPL;
188 static HRESULT WINAPI InstallEngine_SetBaseUrl(IInstallEngine2 *iface, const char *base_name)
190 InstallEngine *This = impl_from_IInstallEngine2(iface);
191 FIXME("(%p)->(%s)\n", This, debugstr_a(base_name));
192 return E_NOTIMPL;
195 static HRESULT WINAPI InstallEngine_SetDownloadDir(IInstallEngine2 *iface, const char *download_dir)
197 InstallEngine *This = impl_from_IInstallEngine2(iface);
198 FIXME("(%p)->(%s)\n", This, debugstr_a(download_dir));
199 return E_NOTIMPL;
202 static HRESULT WINAPI InstallEngine_SetInstallDrive(IInstallEngine2 *iface, char drive)
204 InstallEngine *This = impl_from_IInstallEngine2(iface);
205 FIXME("(%p)->(%c)\n", This, drive);
206 return E_NOTIMPL;
209 static HRESULT WINAPI InstallEngine_SetInstallOptions(IInstallEngine2 *iface, DWORD flags)
211 InstallEngine *This = impl_from_IInstallEngine2(iface);
212 FIXME("(%p)->(%x)\n", This, flags);
213 return E_NOTIMPL;
216 static HRESULT WINAPI InstallEngine_SetHWND(IInstallEngine2 *iface, HWND hwnd)
218 InstallEngine *This = impl_from_IInstallEngine2(iface);
219 FIXME("(%p)->(%p)\n", This, hwnd);
220 return E_NOTIMPL;
223 static HRESULT WINAPI InstallEngine_SetIStream(IInstallEngine2 *iface, IStream *stream)
225 InstallEngine *This = impl_from_IInstallEngine2(iface);
226 FIXME("(%p)->(%p)\n", This, stream);
227 return E_NOTIMPL;
230 static HRESULT WINAPI InstallEngine_Abort(IInstallEngine2 *iface, DWORD flags)
232 InstallEngine *This = impl_from_IInstallEngine2(iface);
233 FIXME("(%p)->(%x)\n", This, flags);
234 return E_NOTIMPL;
237 static HRESULT WINAPI InstallEngine_Suspend(IInstallEngine2 *iface)
239 InstallEngine *This = impl_from_IInstallEngine2(iface);
240 FIXME("(%p)\n", This);
241 return E_NOTIMPL;
244 static HRESULT WINAPI InstallEngine_Resume(IInstallEngine2 *iface)
246 InstallEngine *This = impl_from_IInstallEngine2(iface);
247 FIXME("(%p)\n", This);
248 return E_NOTIMPL;
251 static HRESULT WINAPI InstallEngine2_SetLocalCif(IInstallEngine2 *iface, const char *cif)
253 InstallEngine *This = impl_from_IInstallEngine2(iface);
254 FIXME("(%p)->(%s)\n", This, debugstr_a(cif));
255 return E_NOTIMPL;
258 static HRESULT WINAPI InstallEngine2_GetICifFile(IInstallEngine2 *iface, ICifFile **cif_file)
260 InstallEngine *This = impl_from_IInstallEngine2(iface);
261 FIXME("(%p)->(%p)\n", This, cif_file);
262 return E_NOTIMPL;
265 static const IInstallEngine2Vtbl InstallEngine2Vtbl = {
266 InstallEngine_QueryInterface,
267 InstallEngine_AddRef,
268 InstallEngine_Release,
269 InstallEngine_GetEngineStatus,
270 InstallEngine_SetCifFile,
271 InstallEngine_DownloadComponents,
272 InstallEngine_InstallComponents,
273 InstallEngine_EnumInstallIDs,
274 InstallEngine_EnumDownloadIDs,
275 InstallEngine_IsComponentInstalled,
276 InstallEngine_RegisterInstallEngineCallback,
277 InstallEngine_UnregisterInstallEngineCallback,
278 InstallEngine_SetAction,
279 InstallEngine_GetSizes,
280 InstallEngine_LaunchExtraCommand,
281 InstallEngine_GetDisplayName,
282 InstallEngine_SetBaseUrl,
283 InstallEngine_SetDownloadDir,
284 InstallEngine_SetInstallDrive,
285 InstallEngine_SetInstallOptions,
286 InstallEngine_SetHWND,
287 InstallEngine_SetIStream,
288 InstallEngine_Abort,
289 InstallEngine_Suspend,
290 InstallEngine_Resume,
291 InstallEngine2_SetLocalCif,
292 InstallEngine2_GetICifFile
295 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
297 *ppv = NULL;
299 if(IsEqualGUID(&IID_IUnknown, riid)) {
300 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
301 *ppv = iface;
302 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
303 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
304 *ppv = iface;
307 if(*ppv) {
308 IUnknown_AddRef((IUnknown*)*ppv);
309 return S_OK;
312 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
313 return E_NOINTERFACE;
316 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
318 return 2;
321 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
323 return 1;
326 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
328 return S_OK;
331 static HRESULT WINAPI InstallEngineCF_CreateInstance(IClassFactory *iface, IUnknown *outer,
332 REFIID riid, void **ppv)
334 InstallEngine *engine;
335 HRESULT hres;
337 TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
339 engine = heap_alloc(sizeof(*engine));
340 if(!engine)
341 return E_OUTOFMEMORY;
343 engine->IInstallEngine2_iface.lpVtbl = &InstallEngine2Vtbl;
344 engine->ref = 1;
346 hres = IInstallEngine2_QueryInterface(&engine->IInstallEngine2_iface, riid, ppv);
347 IInstallEngine2_Release(&engine->IInstallEngine2_iface);
348 return hres;
351 static const IClassFactoryVtbl InstallEngineCFVtbl = {
352 ClassFactory_QueryInterface,
353 ClassFactory_AddRef,
354 ClassFactory_Release,
355 InstallEngineCF_CreateInstance,
356 ClassFactory_LockServer
359 static IClassFactory InstallEngineCF = { &InstallEngineCFVtbl };
361 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
363 switch(fdwReason)
365 case DLL_WINE_PREATTACH:
366 return FALSE; /* prefer native version */
367 case DLL_PROCESS_ATTACH:
368 instance = hInstDLL;
369 DisableThreadLibraryCalls(hInstDLL);
370 break;
372 return TRUE;
375 /***********************************************************************
376 * DllGetClassObject (INSENG.@)
378 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
380 if(IsEqualGUID(rclsid, &CLSID_InstallEngine)) {
381 TRACE("(CLSID_InstallEngine %s %p)\n", debugstr_guid(iid), ppv);
382 return IClassFactory_QueryInterface(&InstallEngineCF, iid, ppv);
385 FIXME("(%s %s %p)\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
386 return CLASS_E_CLASSNOTAVAILABLE;
389 /***********************************************************************
390 * DllCanUnloadNow (INSENG.@)
392 HRESULT WINAPI DllCanUnloadNow(void)
394 return S_FALSE;
397 /***********************************************************************
398 * DllRegisterServer (INSENG.@)
400 HRESULT WINAPI DllRegisterServer(void)
402 return __wine_register_resources( instance );
405 /***********************************************************************
406 * DllUnregisterServer (INSENG.@)
408 HRESULT WINAPI DllUnregisterServer(void)
410 return __wine_unregister_resources( instance );
413 BOOL WINAPI CheckTrustEx( LPVOID a, LPVOID b, LPVOID c, LPVOID d, LPVOID e )
415 FIXME("%p %p %p %p %p\n", a, b, c, d, e );
416 return TRUE;
419 /***********************************************************************
420 * DllInstall (INSENG.@)
422 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
424 FIXME("(%s, %s): stub\n", bInstall ? "TRUE" : "FALSE", debugstr_w(cmdline));
425 return S_OK;