2 * SHDOCVW - Internet Explorer Web Control
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2004 Mike McCormack (for CodeWeavers)
6 * Copyright 2008 Detlef Riekenberg
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/unicode.h"
29 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
41 LONG SHDOCVW_refCount = 0;
43 HINSTANCE shdocvw_hinstance = 0;
44 static HMODULE SHDOCVW_hshell32 = 0;
45 static ITypeInfo *wb_typeinfo = NULL;
47 HRESULT get_typeinfo(ITypeInfo **typeinfo)
53 *typeinfo = wb_typeinfo;
57 hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 1, LOCALE_SYSTEM_DEFAULT, &typelib);
59 ERR("LoadRegTypeLib failed: %08x\n", hres);
63 hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IWebBrowser2, &wb_typeinfo);
64 ITypeLib_Release(typelib);
66 *typeinfo = wb_typeinfo;
70 const char *debugstr_variant(const VARIANT *v)
81 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
83 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
85 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
87 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
89 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
91 return wine_dbg_sprintf("{vt %d}", V_VT(v));
95 /*************************************************************************
98 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
100 TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
103 case DLL_PROCESS_ATTACH:
104 shdocvw_hinstance = hinst;
105 register_iewindow_class();
107 case DLL_PROCESS_DETACH:
108 if (SHDOCVW_hshell32) FreeLibrary(SHDOCVW_hshell32);
109 unregister_iewindow_class();
111 ITypeInfo_Release(wb_typeinfo);
117 /*************************************************************************
118 * DllCanUnloadNow (SHDOCVW.@)
120 HRESULT WINAPI DllCanUnloadNow(void)
122 return SHDOCVW_refCount ? S_FALSE : S_OK;
125 /***********************************************************************
126 * DllGetVersion (SHDOCVW.@)
128 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info)
130 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
132 /* this is what IE6 on Windows 98 reports */
133 info->dwMajorVersion = 6;
134 info->dwMinorVersion = 0;
135 info->dwBuildNumber = 2600;
136 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
141 /*************************************************************************
142 * DllInstall (SHDOCVW.@)
144 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
146 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
151 /*************************************************************************
152 * SHDOCVW_LoadShell32
154 * makes sure the handle to shell32 is valid
156 static BOOL SHDOCVW_LoadShell32(void)
158 if (SHDOCVW_hshell32)
160 return ((SHDOCVW_hshell32 = LoadLibraryA("shell32.dll")) != NULL);
163 /***********************************************************************
166 * Called by Win98 explorer.exe main binary, definitely has 0
169 DWORD WINAPI WinList_Init(void)
171 FIXME("(), stub!\n");
175 /***********************************************************************
178 * Called by Win98 explorer.exe main binary, definitely has only one
181 static BOOL (WINAPI *pShellDDEInit)(BOOL start) = NULL;
183 BOOL WINAPI ShellDDEInit(BOOL start)
185 TRACE("(%d)\n", start);
189 if (!SHDOCVW_LoadShell32())
191 pShellDDEInit = (void *)GetProcAddress(SHDOCVW_hshell32, (LPCSTR)188);
195 return pShellDDEInit(start);
200 /***********************************************************************
203 * Called by Win98 explorer.exe main binary, definitely has 0
206 DWORD WINAPI RunInstallUninstallStubs(void)
208 FIXME("(), stub!\n");
212 /***********************************************************************
213 * SetQueryNetSessionCount (SHDOCVW.@)
215 DWORD WINAPI SetQueryNetSessionCount(DWORD arg)
217 FIXME("(%u), stub!\n", arg);
221 /**********************************************************************
222 * Some forwards (by ordinal) to SHLWAPI
225 static void* fetch_shlwapi_ordinal(UINT_PTR ord)
227 static const WCHAR shlwapiW[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
230 if (!h && !(h = GetModuleHandleW(shlwapiW))) return NULL;
231 return (void*)GetProcAddress(h, (const char*)ord);
234 /******************************************************************
235 * WhichPlatformFORWARD (SHDOCVW.@)
237 DWORD WINAPI WhichPlatformFORWARD(void)
239 static DWORD (WINAPI *p)(void);
241 if (p || (p = fetch_shlwapi_ordinal(276))) return p();
242 return 1; /* not integrated, see shlwapi.WhichPlatform */
245 /******************************************************************
246 * StopWatchModeFORWARD (SHDOCVW.@)
248 void WINAPI StopWatchModeFORWARD(void)
250 static void (WINAPI *p)(void);
252 if (p || (p = fetch_shlwapi_ordinal(241))) p();
255 /******************************************************************
256 * StopWatchFlushFORWARD (SHDOCVW.@)
258 void WINAPI StopWatchFlushFORWARD(void)
260 static void (WINAPI *p)(void);
262 if (p || (p = fetch_shlwapi_ordinal(242))) p();
265 /******************************************************************
266 * StopWatchWFORWARD (SHDOCVW.@)
268 DWORD WINAPI StopWatchWFORWARD(DWORD dwClass, LPCWSTR lpszStr, DWORD dwUnknown,
269 DWORD dwMode, DWORD dwTimeStamp)
271 static DWORD (WINAPI *p)(DWORD, LPCWSTR, DWORD, DWORD, DWORD);
273 if (p || (p = fetch_shlwapi_ordinal(243)))
274 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
275 return ERROR_CALL_NOT_IMPLEMENTED;
278 /******************************************************************
279 * StopWatchAFORWARD (SHDOCVW.@)
281 DWORD WINAPI StopWatchAFORWARD(DWORD dwClass, LPCSTR lpszStr, DWORD dwUnknown,
282 DWORD dwMode, DWORD dwTimeStamp)
284 static DWORD (WINAPI *p)(DWORD, LPCSTR, DWORD, DWORD, DWORD);
286 if (p || (p = fetch_shlwapi_ordinal(244)))
287 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
288 return ERROR_CALL_NOT_IMPLEMENTED;
291 /******************************************************************
292 * URLSubRegQueryA (SHDOCVW.151)
294 HRESULT WINAPI URLSubRegQueryA(LPCSTR regpath, LPCSTR name, DWORD type,
295 LPSTR out, DWORD outlen, DWORD unknown)
297 CHAR buffer[INTERNET_MAX_URL_LENGTH];
301 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath), debugstr_a(name),
302 type, out, outlen, unknown);
304 if (!out) return S_OK;
306 len = sizeof(buffer);
307 res = SHRegGetUSValueA(regpath, name, NULL, buffer, &len, FALSE, NULL, 0);
309 lstrcpynA(out, buffer, outlen);
316 /******************************************************************
317 * ParseURLFromOutsideSourceW (SHDOCVW.170)
319 DWORD WINAPI ParseURLFromOutsideSourceW(LPCWSTR url, LPWSTR out, LPDWORD plen, LPDWORD unknown)
321 WCHAR buffer_in[INTERNET_MAX_URL_LENGTH];
322 WCHAR buffer_out[INTERNET_MAX_URL_LENGTH];
330 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url), out, plen, unknown,
331 plen ? *plen : 0, unknown ? *unknown : 0);
333 if (!PathIsURLW(ptr)) {
334 len = sizeof(buffer_in) / sizeof(buffer_in[0]);
336 hr = UrlApplySchemeW(ptr, buffer_in, &len, URL_APPLY_GUESSSCHEME);
337 TRACE("got 0x%x with %s\n", hr, debugstr_w(buffer_in));
339 /* when we can't guess the scheme, use the default scheme */
340 len = sizeof(buffer_in) / sizeof(buffer_in[0]);
341 hr = UrlApplySchemeW(ptr, buffer_in, &len, URL_APPLY_DEFAULT);
345 /* we parsed the url to buffer_in */
350 FIXME("call search hook for %s\n", debugstr_w(ptr));
354 len = sizeof(buffer_out) / sizeof(buffer_out[0]);
355 buffer_out[0] = '\0';
356 hr = UrlCanonicalizeW(ptr, buffer_out, &len, URL_ESCAPE_SPACES_ONLY);
357 needed = lstrlenW(buffer_out)+1;
358 TRACE("got 0x%x with %s (need %d)\n", hr, debugstr_w(buffer_out), needed);
360 if (*plen >= needed) {
362 lstrcpyW(out, buffer_out);
370 TRACE("=> %d\n", res);
374 /******************************************************************
375 * ParseURLFromOutsideSourceA (SHDOCVW.169)
377 * See ParseURLFromOutsideSourceW
379 DWORD WINAPI ParseURLFromOutsideSourceA(LPCSTR url, LPSTR out, LPDWORD plen, LPDWORD unknown)
381 WCHAR buffer[INTERNET_MAX_URL_LENGTH];
387 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url), out, plen, unknown,
388 plen ? *plen : 0, unknown ? *unknown : 0);
391 len = MultiByteToWideChar(CP_ACP, 0, url, -1, NULL, 0);
392 urlW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
393 MultiByteToWideChar(CP_ACP, 0, url, -1, urlW, len);
396 len = sizeof(buffer) / sizeof(buffer[0]);
397 res = ParseURLFromOutsideSourceW(urlW, buffer, &len, unknown);
398 HeapFree(GetProcessHeap(), 0, urlW);
400 needed = WideCharToMultiByte(CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL);
403 if (*plen >= needed) {
405 WideCharToMultiByte(CP_ACP, 0, buffer, -1, out, *plen, NULL, NULL);
413 TRACE("=> %d\n", res);
417 /******************************************************************
418 * IEParseDisplayNameWithBCW (SHDOCVW.218)
420 HRESULT WINAPI IEParseDisplayNameWithBCW(DWORD codepage, LPCWSTR lpszDisplayName, LPBC pbc, LPITEMIDLIST *ppidl)
422 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
423 FIXME("stub: 0x%x %s %p %p\n",codepage,debugstr_w(lpszDisplayName),pbc,ppidl);
427 /******************************************************************
428 * SHRestricted2W (SHDOCVW.159)
430 DWORD WINAPI SHRestricted2W(DWORD res, LPCWSTR url, DWORD reserved)
432 FIXME("(%d %s %d) stub\n", res, debugstr_w(url), reserved);
436 /******************************************************************
437 * SHRestricted2A (SHDOCVW.158)
441 DWORD WINAPI SHRestricted2A(DWORD restriction, LPCSTR url, DWORD reserved)
446 TRACE("(%d, %s, %d)\n", restriction, debugstr_a(url), reserved);
448 DWORD len = MultiByteToWideChar(CP_ACP, 0, url, -1, NULL, 0);
449 urlW = heap_alloc(len * sizeof(WCHAR));
450 MultiByteToWideChar(CP_ACP, 0, url, -1, urlW, len);
452 res = SHRestricted2W(restriction, urlW, reserved);
457 /******************************************************************
458 * ImportPrivacySettings (SHDOCVW.@)
460 * Import global and/or per site privacy preferences from an xml file
463 * filename [I] XML file to use
464 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
465 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
468 * Success: TRUE (the privacy preferences where updated)
469 * Failure: FALSE (the privacy preferences are unchanged)
472 * Set the flag to TRUE, when the related privacy preferences in the xml file
473 * should be used (parsed and overwrite the current settings).
474 * On return, the flag is TRUE, when the related privacy settings where used
477 BOOL WINAPI ImportPrivacySettings(LPCWSTR filename, BOOL *pGlobalPrefs, BOOL * pPerSitePrefs)
479 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename),
480 pGlobalPrefs, pGlobalPrefs ? *pGlobalPrefs : 0,
481 pPerSitePrefs, pPerSitePrefs ? *pPerSitePrefs : 0);
483 if (pGlobalPrefs) *pGlobalPrefs = FALSE;
484 if (pPerSitePrefs) *pPerSitePrefs = FALSE;