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 /***********************************************************************
215 * Called by Emerge Desktop (alternative Windows Shell).
217 DWORD WINAPI RunInstallUninstallStubs2(void)
219 FIXME("(), stub!\n");
223 /***********************************************************************
224 * SetQueryNetSessionCount (SHDOCVW.@)
226 DWORD WINAPI SetQueryNetSessionCount(DWORD arg)
228 FIXME("(%u), stub!\n", arg);
232 /**********************************************************************
233 * Some forwards (by ordinal) to SHLWAPI
236 static void* fetch_shlwapi_ordinal(UINT_PTR ord)
238 static const WCHAR shlwapiW[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
241 if (!h && !(h = GetModuleHandleW(shlwapiW))) return NULL;
242 return (void*)GetProcAddress(h, (const char*)ord);
245 /******************************************************************
246 * WhichPlatformFORWARD (SHDOCVW.@)
248 DWORD WINAPI WhichPlatformFORWARD(void)
250 static DWORD (WINAPI *p)(void);
252 if (p || (p = fetch_shlwapi_ordinal(276))) return p();
253 return 1; /* not integrated, see shlwapi.WhichPlatform */
256 /******************************************************************
257 * StopWatchModeFORWARD (SHDOCVW.@)
259 void WINAPI StopWatchModeFORWARD(void)
261 static void (WINAPI *p)(void);
263 if (p || (p = fetch_shlwapi_ordinal(241))) p();
266 /******************************************************************
267 * StopWatchFlushFORWARD (SHDOCVW.@)
269 void WINAPI StopWatchFlushFORWARD(void)
271 static void (WINAPI *p)(void);
273 if (p || (p = fetch_shlwapi_ordinal(242))) p();
276 /******************************************************************
277 * StopWatchWFORWARD (SHDOCVW.@)
279 DWORD WINAPI StopWatchWFORWARD(DWORD dwClass, LPCWSTR lpszStr, DWORD dwUnknown,
280 DWORD dwMode, DWORD dwTimeStamp)
282 static DWORD (WINAPI *p)(DWORD, LPCWSTR, DWORD, DWORD, DWORD);
284 if (p || (p = fetch_shlwapi_ordinal(243)))
285 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
286 return ERROR_CALL_NOT_IMPLEMENTED;
289 /******************************************************************
290 * StopWatchAFORWARD (SHDOCVW.@)
292 DWORD WINAPI StopWatchAFORWARD(DWORD dwClass, LPCSTR lpszStr, DWORD dwUnknown,
293 DWORD dwMode, DWORD dwTimeStamp)
295 static DWORD (WINAPI *p)(DWORD, LPCSTR, DWORD, DWORD, DWORD);
297 if (p || (p = fetch_shlwapi_ordinal(244)))
298 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
299 return ERROR_CALL_NOT_IMPLEMENTED;
302 /******************************************************************
303 * URLSubRegQueryA (SHDOCVW.151)
305 HRESULT WINAPI URLSubRegQueryA(LPCSTR regpath, LPCSTR name, DWORD type,
306 LPSTR out, DWORD outlen, DWORD unknown)
308 CHAR buffer[INTERNET_MAX_URL_LENGTH];
312 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath), debugstr_a(name),
313 type, out, outlen, unknown);
315 if (!out) return S_OK;
317 len = sizeof(buffer);
318 res = SHRegGetUSValueA(regpath, name, NULL, buffer, &len, FALSE, NULL, 0);
320 lstrcpynA(out, buffer, outlen);
327 /******************************************************************
328 * ParseURLFromOutsideSourceW (SHDOCVW.170)
330 DWORD WINAPI ParseURLFromOutsideSourceW(LPCWSTR url, LPWSTR out, LPDWORD plen, LPDWORD unknown)
332 WCHAR buffer_in[INTERNET_MAX_URL_LENGTH];
333 WCHAR buffer_out[INTERNET_MAX_URL_LENGTH];
341 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url), out, plen, unknown,
342 plen ? *plen : 0, unknown ? *unknown : 0);
344 if (!PathIsURLW(ptr)) {
345 len = sizeof(buffer_in) / sizeof(buffer_in[0]);
347 hr = UrlApplySchemeW(ptr, buffer_in, &len, URL_APPLY_GUESSSCHEME | URL_APPLY_DEFAULT);
348 TRACE("got 0x%x with %s\n", hr, debugstr_w(buffer_in));
350 /* we parsed the url to buffer_in */
355 FIXME("call search hook for %s\n", debugstr_w(ptr));
359 len = sizeof(buffer_out) / sizeof(buffer_out[0]);
360 buffer_out[0] = '\0';
361 hr = UrlCanonicalizeW(ptr, buffer_out, &len, URL_ESCAPE_SPACES_ONLY);
362 needed = lstrlenW(buffer_out)+1;
363 TRACE("got 0x%x with %s (need %d)\n", hr, debugstr_w(buffer_out), needed);
365 if (*plen >= needed) {
367 lstrcpyW(out, buffer_out);
375 TRACE("=> %d\n", res);
379 /******************************************************************
380 * ParseURLFromOutsideSourceA (SHDOCVW.169)
382 * See ParseURLFromOutsideSourceW
384 DWORD WINAPI ParseURLFromOutsideSourceA(LPCSTR url, LPSTR out, LPDWORD plen, LPDWORD unknown)
386 WCHAR buffer[INTERNET_MAX_URL_LENGTH];
392 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url), out, plen, unknown,
393 plen ? *plen : 0, unknown ? *unknown : 0);
396 len = MultiByteToWideChar(CP_ACP, 0, url, -1, NULL, 0);
397 urlW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
398 MultiByteToWideChar(CP_ACP, 0, url, -1, urlW, len);
401 len = sizeof(buffer) / sizeof(buffer[0]);
402 res = ParseURLFromOutsideSourceW(urlW, buffer, &len, unknown);
403 HeapFree(GetProcessHeap(), 0, urlW);
405 needed = WideCharToMultiByte(CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL);
408 if (*plen >= needed) {
410 WideCharToMultiByte(CP_ACP, 0, buffer, -1, out, *plen, NULL, NULL);
418 TRACE("=> %d\n", res);
422 /******************************************************************
423 * IEParseDisplayNameWithBCW (SHDOCVW.218)
425 HRESULT WINAPI IEParseDisplayNameWithBCW(DWORD codepage, LPCWSTR lpszDisplayName, LPBC pbc, LPITEMIDLIST *ppidl)
427 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
428 FIXME("stub: 0x%x %s %p %p\n",codepage,debugstr_w(lpszDisplayName),pbc,ppidl);
432 /******************************************************************
433 * SHRestricted2W (SHDOCVW.159)
435 DWORD WINAPI SHRestricted2W(DWORD res, LPCWSTR url, DWORD reserved)
437 FIXME("(%d %s %d) stub\n", res, debugstr_w(url), reserved);
441 /******************************************************************
442 * SHRestricted2A (SHDOCVW.158)
446 DWORD WINAPI SHRestricted2A(DWORD restriction, LPCSTR url, DWORD reserved)
451 TRACE("(%d, %s, %d)\n", restriction, debugstr_a(url), reserved);
453 DWORD len = MultiByteToWideChar(CP_ACP, 0, url, -1, NULL, 0);
454 urlW = heap_alloc(len * sizeof(WCHAR));
455 MultiByteToWideChar(CP_ACP, 0, url, -1, urlW, len);
457 res = SHRestricted2W(restriction, urlW, reserved);
462 /******************************************************************
463 * ImportPrivacySettings (SHDOCVW.@)
465 * Import global and/or per site privacy preferences from an xml file
468 * filename [I] XML file to use
469 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
470 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
473 * Success: TRUE (the privacy preferences where updated)
474 * Failure: FALSE (the privacy preferences are unchanged)
477 * Set the flag to TRUE, when the related privacy preferences in the xml file
478 * should be used (parsed and overwrite the current settings).
479 * On return, the flag is TRUE, when the related privacy settings where used
482 BOOL WINAPI ImportPrivacySettings(LPCWSTR filename, BOOL *pGlobalPrefs, BOOL * pPerSitePrefs)
484 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename),
485 pGlobalPrefs, pGlobalPrefs ? *pGlobalPrefs : 0,
486 pPerSitePrefs, pPerSitePrefs ? *pPerSitePrefs : 0);
488 if (pGlobalPrefs) *pGlobalPrefs = FALSE;
489 if (pPerSitePrefs) *pPerSitePrefs = FALSE;