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
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 extern HRESULT HTMLDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj);
38 /* For the moment, do nothing here. */
39 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
42 case DLL_PROCESS_ATTACH:
43 DisableThreadLibraryCalls(hInstDLL);
45 case DLL_PROCESS_DETACH:
51 /******************************************************************************
55 IClassFactory ITF_IClassFactory;
58 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
61 struct object_creation_info
65 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
68 static const struct object_creation_info object_creation[] =
70 { &CLSID_HTMLDocument, "HTMLDocument", HTMLDocument_create },
74 HTMLCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
76 ICOM_THIS(IClassFactoryImpl,iface);
78 if (IsEqualGUID(riid, &IID_IUnknown)
79 || IsEqualGUID(riid, &IID_IClassFactory))
81 IClassFactory_AddRef(iface);
86 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
90 static ULONG WINAPI HTMLCF_AddRef(LPCLASSFACTORY iface) {
91 ICOM_THIS(IClassFactoryImpl,iface);
95 static ULONG WINAPI HTMLCF_Release(LPCLASSFACTORY iface) {
96 ICOM_THIS(IClassFactoryImpl,iface);
98 ULONG ref = --This->ref;
101 HeapFree(GetProcessHeap(), 0, This);
107 static HRESULT WINAPI HTMLCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
108 REFIID riid, LPVOID *ppobj) {
109 ICOM_THIS(IClassFactoryImpl,iface);
113 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
115 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
120 hres = IUnknown_QueryInterface(punk, riid, ppobj);
125 IUnknown_Release(punk);
129 static HRESULT WINAPI HTMLCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
130 ICOM_THIS(IClassFactoryImpl,iface);
131 FIXME("(%p)->(%d),stub!\n",This,dolock);
135 static ICOM_VTABLE(IClassFactory) HTMLCF_Vtbl =
137 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
138 HTMLCF_QueryInterface,
141 HTMLCF_CreateInstance,
146 HRESULT WINAPI MSHTML_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
149 IClassFactoryImpl *factory;
151 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
153 if ( !IsEqualGUID( &IID_IClassFactory, iid )
154 && ! IsEqualGUID( &IID_IUnknown, iid) )
155 return E_NOINTERFACE;
157 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
159 if (IsEqualGUID(object_creation[i].clsid, rclsid))
163 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
165 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
166 return CLASS_E_CLASSNOTAVAILABLE;
169 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
171 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
172 if (factory == NULL) return E_OUTOFMEMORY;
174 factory->ITF_IClassFactory.lpVtbl = &HTMLCF_Vtbl;
177 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
179 *ppv = &(factory->ITF_IClassFactory);
181 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
186 HRESULT WINAPI MSHTML_DllCanUnloadNow(void)
192 /* appears to have the same prototype as WinMain */
193 INT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst,
194 LPCSTR szCmdLine, INT nCmdShow )
196 FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow );