HTTP_DealWithProxy: Only add http:// to proxy string when needed.
[wine/multimedia.git] / dlls / mshtml / main.c
blobf60d69078096124dc0896994d26c0fafb3634ee3
1 /*
2 * MSHTML Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
31 #include "uuids.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 extern HRESULT HTMLDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj);
39 /* For the moment, do nothing here. */
40 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
42 switch(fdwReason) {
43 case DLL_PROCESS_ATTACH:
44 DisableThreadLibraryCalls(hInstDLL);
45 break;
46 case DLL_PROCESS_DETACH:
47 break;
49 return TRUE;
52 /******************************************************************************
53 * MSHTML ClassFactory
55 typedef struct {
56 IClassFactory ITF_IClassFactory;
58 DWORD ref;
59 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
60 } IClassFactoryImpl;
62 struct object_creation_info
64 const CLSID *clsid;
65 LPCSTR szClassName;
66 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
69 static const struct object_creation_info object_creation[] =
71 { &CLSID_HTMLDocument, "HTMLDocument", HTMLDocument_create },
74 static HRESULT WINAPI
75 HTMLCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
77 ICOM_THIS(IClassFactoryImpl,iface);
79 if (IsEqualGUID(riid, &IID_IUnknown)
80 || IsEqualGUID(riid, &IID_IClassFactory))
82 IClassFactory_AddRef(iface);
83 *ppobj = This;
84 return S_OK;
87 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
88 return E_NOINTERFACE;
91 static ULONG WINAPI HTMLCF_AddRef(LPCLASSFACTORY iface) {
92 ICOM_THIS(IClassFactoryImpl,iface);
93 return ++(This->ref);
96 static ULONG WINAPI HTMLCF_Release(LPCLASSFACTORY iface) {
97 ICOM_THIS(IClassFactoryImpl,iface);
99 ULONG ref = --This->ref;
101 if (ref == 0)
102 HeapFree(GetProcessHeap(), 0, This);
104 return ref;
108 static HRESULT WINAPI HTMLCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
109 REFIID riid, LPVOID *ppobj) {
110 ICOM_THIS(IClassFactoryImpl,iface);
111 HRESULT hres;
112 LPUNKNOWN punk;
114 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
116 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
117 if (FAILED(hres)) {
118 *ppobj = NULL;
119 return hres;
121 hres = IUnknown_QueryInterface(punk, riid, ppobj);
122 if (FAILED(hres)) {
123 *ppobj = NULL;
124 return hres;
126 IUnknown_Release(punk);
127 return hres;
130 static HRESULT WINAPI HTMLCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
131 ICOM_THIS(IClassFactoryImpl,iface);
132 FIXME("(%p)->(%d),stub!\n",This,dolock);
133 return S_OK;
136 static ICOM_VTABLE(IClassFactory) HTMLCF_Vtbl =
138 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
139 HTMLCF_QueryInterface,
140 HTMLCF_AddRef,
141 HTMLCF_Release,
142 HTMLCF_CreateInstance,
143 HTMLCF_LockServer
147 HRESULT WINAPI MSHTML_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
149 int i;
150 IClassFactoryImpl *factory;
152 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
154 if ( !IsEqualGUID( &IID_IClassFactory, iid )
155 && ! IsEqualGUID( &IID_IUnknown, iid) )
156 return E_NOINTERFACE;
158 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
160 if (IsEqualGUID(object_creation[i].clsid, rclsid))
161 break;
164 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
166 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
167 return CLASS_E_CLASSNOTAVAILABLE;
170 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
172 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
173 if (factory == NULL) return E_OUTOFMEMORY;
175 factory->ITF_IClassFactory.lpVtbl = &HTMLCF_Vtbl;
176 factory->ref = 1;
178 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
180 *ppv = &(factory->ITF_IClassFactory);
182 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
184 return S_OK;
187 HRESULT WINAPI MSHTML_DllCanUnloadNow(void)
189 FIXME("\n");
190 return S_FALSE;
193 /* appears to have the same prototype as WinMain */
194 INT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst,
195 LPCSTR szCmdLine, INT nCmdShow )
197 FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow );
198 return 0;