wbemprox: Add a partial implementation of Win32_NetworkAdapterConfiguration.
[wine.git] / dlls / winhttp / main.c
blob5827c108f6fab62bb738f5cd61f75831e90f1f34
1 /*
2 * Copyright 2007 Jacek Caban 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
19 #define COBJMACROS
20 #include "config.h"
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "objbase.h"
26 #include "rpcproxy.h"
27 #include "httprequest.h"
28 #include "winhttp.h"
30 #include "wine/debug.h"
31 #include "winhttp_private.h"
33 static HINSTANCE instance;
35 WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
37 /******************************************************************
38 * DllMain (winhttp.@)
40 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
42 switch(fdwReason)
44 case DLL_PROCESS_ATTACH:
45 instance = hInstDLL;
46 DisableThreadLibraryCalls(hInstDLL);
47 break;
48 case DLL_PROCESS_DETACH:
49 if (lpv) break;
50 netconn_unload();
51 break;
53 return TRUE;
56 typedef HRESULT (*fnCreateInstance)( IUnknown *outer, void **obj );
58 struct winhttp_cf
60 IClassFactory IClassFactory_iface;
61 fnCreateInstance pfnCreateInstance;
64 static inline struct winhttp_cf *impl_from_IClassFactory( IClassFactory *iface )
66 return CONTAINING_RECORD( iface, struct winhttp_cf, IClassFactory_iface );
69 static HRESULT WINAPI requestcf_QueryInterface(
70 IClassFactory *iface,
71 REFIID riid,
72 void **obj )
74 if (IsEqualGUID( riid, &IID_IUnknown ) ||
75 IsEqualGUID( riid, &IID_IClassFactory ))
77 IClassFactory_AddRef( iface );
78 *obj = iface;
79 return S_OK;
81 FIXME("interface %s not implemented\n", debugstr_guid(riid));
82 return E_NOINTERFACE;
85 static ULONG WINAPI requestcf_AddRef(
86 IClassFactory *iface )
88 return 2;
91 static ULONG WINAPI requestcf_Release(
92 IClassFactory *iface )
94 return 1;
97 static HRESULT WINAPI requestcf_CreateInstance(
98 IClassFactory *iface,
99 LPUNKNOWN outer,
100 REFIID riid,
101 void **obj )
103 struct winhttp_cf *cf = impl_from_IClassFactory( iface );
104 IUnknown *unknown;
105 HRESULT hr;
107 TRACE("%p, %s, %p\n", outer, debugstr_guid(riid), obj);
109 *obj = NULL;
110 if (outer)
111 return CLASS_E_NOAGGREGATION;
113 hr = cf->pfnCreateInstance( outer, (void **)&unknown );
114 if (FAILED(hr))
115 return hr;
117 hr = IUnknown_QueryInterface( unknown, riid, obj );
118 if (FAILED(hr))
119 return hr;
121 IUnknown_Release( unknown );
122 return hr;
125 static HRESULT WINAPI requestcf_LockServer(
126 IClassFactory *iface,
127 BOOL dolock )
129 FIXME("%p, %d\n", iface, dolock);
130 return S_OK;
133 static const struct IClassFactoryVtbl winhttp_cf_vtbl =
135 requestcf_QueryInterface,
136 requestcf_AddRef,
137 requestcf_Release,
138 requestcf_CreateInstance,
139 requestcf_LockServer
142 static struct winhttp_cf request_cf = { { &winhttp_cf_vtbl }, WinHttpRequest_create };
144 /******************************************************************
145 * DllGetClassObject (winhttp.@)
147 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
149 IClassFactory *cf = NULL;
151 TRACE("%s, %s, %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
153 if (IsEqualGUID( rclsid, &CLSID_WinHttpRequest ))
155 cf = &request_cf.IClassFactory_iface;
157 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
158 return IClassFactory_QueryInterface( cf, riid, ppv );
161 /******************************************************************
162 * DllCanUnloadNow (winhttp.@)
164 HRESULT WINAPI DllCanUnloadNow(void)
166 return S_FALSE;
169 /***********************************************************************
170 * DllRegisterServer (winhttp.@)
172 HRESULT WINAPI DllRegisterServer(void)
174 return __wine_register_resources( instance );
177 /***********************************************************************
178 * DllUnregisterServer (winhttp.@)
180 HRESULT WINAPI DllUnregisterServer(void)
182 return __wine_unregister_resources( instance );