2006-06-14 22:35:13 +02:00
|
|
|
/*
|
2007-10-10 14:44:07 +02:00
|
|
|
* Copyright 2006-2007 Jacek Caban for CodeWeavers
|
2006-06-14 22:35:13 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2007-10-10 14:44:07 +02:00
|
|
|
#include <fcntl.h>
|
2007-10-14 14:35:14 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2006-06-14 22:35:13 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "commctrl.h"
|
|
|
|
#include "advpub.h"
|
2007-06-06 19:44:20 +02:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "shellapi.h"
|
2006-06-14 22:35:13 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
2007-10-10 14:44:07 +02:00
|
|
|
#include "wine/library.h"
|
2006-06-14 22:35:13 +02:00
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2009-12-03 15:08:30 +01:00
|
|
|
#ifdef __i386__
|
|
|
|
#define GECKO_ARCH "x86"
|
2010-08-25 14:22:39 +02:00
|
|
|
#elif defined(__x86_64__)
|
|
|
|
#define GECKO_ARCH "x86_64"
|
2009-12-03 15:08:30 +01:00
|
|
|
#else
|
|
|
|
#define GECKO_ARCH ""
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GECKO_FILE_NAME "wine_gecko-" GECKO_VERSION "-" GECKO_ARCH ".cab"
|
2007-10-10 14:44:07 +02:00
|
|
|
|
|
|
|
static const WCHAR mshtml_keyW[] =
|
|
|
|
{'S','o','f','t','w','a','r','e',
|
|
|
|
'\\','W','i','n','e',
|
|
|
|
'\\','M','S','H','T','M','L',0};
|
|
|
|
|
2006-06-14 22:35:13 +02:00
|
|
|
static HWND install_dialog = NULL;
|
|
|
|
static LPWSTR url = NULL;
|
|
|
|
|
|
|
|
static void set_status(DWORD id)
|
|
|
|
{
|
|
|
|
HWND status = GetDlgItem(install_dialog, ID_DWL_STATUS);
|
|
|
|
WCHAR buf[64];
|
|
|
|
|
|
|
|
LoadStringW(hInst, id, buf, sizeof(buf)/sizeof(WCHAR));
|
|
|
|
SendMessageW(status, WM_SETTEXT, 0, (LPARAM)buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_registry(LPCSTR install_dir)
|
|
|
|
{
|
2007-06-06 19:44:20 +02:00
|
|
|
WCHAR mshtml_key[100];
|
2006-06-14 22:35:13 +02:00
|
|
|
LPWSTR gecko_path;
|
|
|
|
HKEY hkey;
|
2008-04-21 23:23:18 +02:00
|
|
|
DWORD res, len;
|
2006-06-14 22:35:13 +02:00
|
|
|
|
|
|
|
static const WCHAR wszGeckoPath[] = {'G','e','c','k','o','P','a','t','h',0};
|
|
|
|
static const WCHAR wszWineGecko[] = {'w','i','n','e','_','g','e','c','k','o',0};
|
|
|
|
|
2007-10-10 14:44:07 +02:00
|
|
|
memcpy(mshtml_key, mshtml_keyW, sizeof(mshtml_keyW));
|
|
|
|
mshtml_key[sizeof(mshtml_keyW)/sizeof(WCHAR)-1] = '\\';
|
2007-06-06 19:44:20 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, GECKO_VERSION, sizeof(GECKO_VERSION),
|
2007-10-10 14:44:07 +02:00
|
|
|
mshtml_key+sizeof(mshtml_keyW)/sizeof(WCHAR),
|
|
|
|
(sizeof(mshtml_key)-sizeof(mshtml_keyW))/sizeof(WCHAR));
|
2007-06-06 19:44:20 +02:00
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\MSHTML\<version> */
|
|
|
|
res = RegCreateKeyW(HKEY_CURRENT_USER, mshtml_key, &hkey);
|
2006-06-14 22:35:13 +02:00
|
|
|
if(res != ERROR_SUCCESS) {
|
2007-06-06 19:44:20 +02:00
|
|
|
ERR("Faild to create MSHTML key: %d\n", res);
|
2006-06-14 22:35:13 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, install_dir, -1, NULL, 0)-1;
|
2007-12-05 21:52:31 +01:00
|
|
|
gecko_path = heap_alloc((len+1)*sizeof(WCHAR)+sizeof(wszWineGecko));
|
2008-04-10 13:01:52 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, install_dir, -1, gecko_path, len+1);
|
2006-06-30 23:38:43 +02:00
|
|
|
|
|
|
|
if (len && gecko_path[len-1] != '\\')
|
|
|
|
gecko_path[len++] = '\\';
|
|
|
|
|
2006-06-14 22:35:13 +02:00
|
|
|
memcpy(gecko_path+len, wszWineGecko, sizeof(wszWineGecko));
|
|
|
|
|
|
|
|
res = RegSetValueExW(hkey, wszGeckoPath, 0, REG_SZ, (LPVOID)gecko_path,
|
|
|
|
len*sizeof(WCHAR)+sizeof(wszWineGecko));
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(gecko_path);
|
2006-06-14 22:35:13 +02:00
|
|
|
RegCloseKey(hkey);
|
2007-11-02 19:51:53 +01:00
|
|
|
if(res != ERROR_SUCCESS)
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Failed to set GeckoPath value: %08x\n", res);
|
2006-06-14 22:35:13 +02:00
|
|
|
}
|
|
|
|
|
2007-10-10 14:44:07 +02:00
|
|
|
static BOOL install_cab(LPCWSTR file_name)
|
|
|
|
{
|
|
|
|
HMODULE advpack;
|
|
|
|
char install_dir[MAX_PATH];
|
2008-02-26 12:13:07 +01:00
|
|
|
HRESULT (WINAPI *pExtractFilesA)(LPCSTR,LPCSTR,DWORD,LPCSTR,LPVOID,DWORD);
|
2007-10-10 14:44:07 +02:00
|
|
|
LPSTR file_name_a;
|
2008-03-26 15:32:46 +01:00
|
|
|
DWORD res;
|
2007-10-10 14:44:07 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_w(file_name));
|
|
|
|
|
2009-08-04 14:04:03 +02:00
|
|
|
GetSystemDirectoryA(install_dir, sizeof(install_dir));
|
2007-10-10 14:44:07 +02:00
|
|
|
strcat(install_dir, "\\gecko\\");
|
|
|
|
res = CreateDirectoryA(install_dir, NULL);
|
|
|
|
if(!res && GetLastError() != ERROR_ALREADY_EXISTS) {
|
|
|
|
ERR("Could not create directory: %08u\n", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcat(install_dir, GECKO_VERSION);
|
|
|
|
res = CreateDirectoryA(install_dir, NULL);
|
|
|
|
if(!res && GetLastError() != ERROR_ALREADY_EXISTS) {
|
|
|
|
ERR("Could not create directory: %08u\n", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
advpack = LoadLibraryW(wszAdvpack);
|
2008-02-26 12:13:07 +01:00
|
|
|
pExtractFilesA = (void *)GetProcAddress(advpack, "ExtractFiles");
|
2007-10-10 14:44:07 +02:00
|
|
|
|
|
|
|
/* FIXME: Use unicode version (not yet implemented) */
|
2008-03-26 15:32:46 +01:00
|
|
|
file_name_a = heap_strdupWtoA(file_name);
|
2007-10-10 14:44:07 +02:00
|
|
|
hres = pExtractFilesA(file_name_a, install_dir, 0, NULL, NULL, 0);
|
|
|
|
FreeLibrary(advpack);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(file_name_a);
|
2007-10-10 14:44:07 +02:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("Could not extract package: %08x\n", hres);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_registry(install_dir);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL install_from_unix_file(const char *file_name)
|
|
|
|
{
|
|
|
|
LPWSTR dos_file_name;
|
|
|
|
int fd;
|
|
|
|
BOOL ret;
|
|
|
|
|
2009-11-18 21:46:00 +01:00
|
|
|
static WCHAR * (CDECL *wine_get_dos_file_name)(const char*);
|
2007-10-10 14:44:07 +02:00
|
|
|
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
|
|
|
|
|
|
|
|
fd = open(file_name, O_RDONLY);
|
|
|
|
if(fd == -1) {
|
|
|
|
TRACE("%s not found\n", debugstr_a(file_name));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
2009-02-04 19:11:10 +01:00
|
|
|
if(!wine_get_dos_file_name)
|
2007-10-10 14:44:07 +02:00
|
|
|
wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleW(kernel32W), "wine_get_dos_file_name");
|
|
|
|
|
2009-02-04 19:11:10 +01:00
|
|
|
if(wine_get_dos_file_name) { /* Wine UNIX mode */
|
|
|
|
dos_file_name = wine_get_dos_file_name(file_name);
|
|
|
|
if(!dos_file_name) {
|
|
|
|
ERR("Could not get dos file name of %s\n", debugstr_a(file_name));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else { /* Windows mode */
|
|
|
|
UINT res;
|
|
|
|
WARN("Could not get wine_get_dos_file_name function, calling install_cab directly.\n");
|
|
|
|
res = MultiByteToWideChar( CP_ACP, 0, file_name, -1, 0, 0);
|
|
|
|
dos_file_name = heap_alloc (res*sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, file_name, -1, dos_file_name, res);
|
2007-10-10 14:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = install_cab(dos_file_name);
|
|
|
|
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(dos_file_name);
|
2007-10-10 14:44:07 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL install_from_registered_dir(void)
|
|
|
|
{
|
|
|
|
char *file_name;
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD res, type, size = MAX_PATH;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\MSHTML */
|
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, mshtml_keyW, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
2007-12-05 21:52:31 +01:00
|
|
|
file_name = heap_alloc(size+sizeof(GECKO_FILE_NAME));
|
2010-06-02 18:44:41 +02:00
|
|
|
res = RegGetValueA(hkey, NULL, "GeckoCabDir", RRF_RT_ANY, &type, (PBYTE)file_name, &size);
|
2007-10-10 14:44:07 +02:00
|
|
|
if(res == ERROR_MORE_DATA) {
|
2007-12-05 21:52:31 +01:00
|
|
|
file_name = heap_realloc(file_name, size+sizeof(GECKO_FILE_NAME));
|
2010-06-02 18:44:41 +02:00
|
|
|
res = RegGetValueA(hkey, NULL, "GeckoCabDir", RRF_RT_ANY, &type, (PBYTE)file_name, &size);
|
2007-10-10 14:44:07 +02:00
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
2010-06-02 18:44:41 +02:00
|
|
|
if(res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ)) {
|
2007-12-31 00:51:04 +01:00
|
|
|
heap_free(file_name);
|
2007-10-10 14:44:07 +02:00
|
|
|
return FALSE;
|
2007-12-31 00:51:04 +01:00
|
|
|
}
|
2007-10-10 14:44:07 +02:00
|
|
|
|
|
|
|
strcat(file_name, GECKO_FILE_NAME);
|
|
|
|
|
|
|
|
TRACE("Trying %s\n", debugstr_a(file_name));
|
|
|
|
|
|
|
|
ret = install_from_unix_file(file_name);
|
|
|
|
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(file_name);
|
2007-10-10 14:44:07 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL install_from_default_dir(void)
|
|
|
|
{
|
2007-10-18 15:06:54 +02:00
|
|
|
const char *data_dir, *subdir;
|
2007-10-10 14:44:07 +02:00
|
|
|
char *file_name;
|
2007-10-18 15:06:54 +02:00
|
|
|
int len, len2;
|
2007-10-10 14:44:07 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2007-10-18 15:06:54 +02:00
|
|
|
if((data_dir = wine_get_data_dir()))
|
|
|
|
subdir = "/gecko/";
|
|
|
|
else if((data_dir = wine_get_build_dir()))
|
|
|
|
subdir = "/../gecko/";
|
|
|
|
else
|
|
|
|
return FALSE;
|
2007-10-10 14:44:07 +02:00
|
|
|
|
|
|
|
len = strlen(data_dir);
|
2007-10-18 15:06:54 +02:00
|
|
|
len2 = strlen(subdir);
|
2007-10-10 14:44:07 +02:00
|
|
|
|
2007-12-05 21:52:31 +01:00
|
|
|
file_name = heap_alloc(len+len2+sizeof(GECKO_FILE_NAME));
|
2007-10-10 14:44:07 +02:00
|
|
|
memcpy(file_name, data_dir, len);
|
2007-10-18 15:06:54 +02:00
|
|
|
memcpy(file_name+len, subdir, len2);
|
|
|
|
memcpy(file_name+len+len2, GECKO_FILE_NAME, sizeof(GECKO_FILE_NAME));
|
2007-10-10 14:44:07 +02:00
|
|
|
|
|
|
|
ret = install_from_unix_file(file_name);
|
|
|
|
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(file_name);
|
2010-10-01 15:30:19 +02:00
|
|
|
|
2010-10-04 13:28:37 +02:00
|
|
|
if (!ret)
|
|
|
|
ret = install_from_unix_file( GECKO_DATADIR "/wine/gecko/" GECKO_FILE_NAME);
|
|
|
|
if (!ret && strcmp( GECKO_DATADIR, "/usr/share" ))
|
|
|
|
ret = install_from_unix_file("/usr/share/wine/gecko/" GECKO_FILE_NAME);
|
|
|
|
return ret;
|
2007-10-10 14:44:07 +02:00
|
|
|
}
|
|
|
|
|
2006-06-14 22:35:13 +02:00
|
|
|
static HRESULT WINAPI InstallCallback_QueryInterface(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IBindStatusCallback, riid)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InstallCallback_AddRef(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InstallCallback_Release(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnStartBinding(IBindStatusCallback *iface,
|
|
|
|
DWORD dwReserved, IBinding *pib)
|
|
|
|
{
|
|
|
|
set_status(IDS_DOWNLOADING);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_GetPriority(IBindStatusCallback *iface,
|
|
|
|
LONG *pnPriority)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnLowResource(IBindStatusCallback *iface,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
|
|
|
|
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
|
|
|
|
{
|
|
|
|
HWND progress = GetDlgItem(install_dialog, ID_DWL_PROGRESS);
|
|
|
|
|
|
|
|
if(ulProgressMax)
|
|
|
|
SendMessageW(progress, PBM_SETRANGE32, 0, ulProgressMax);
|
|
|
|
if(ulProgress)
|
|
|
|
SendMessageW(progress, PBM_SETPOS, ulProgress, 0);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
|
|
|
|
HRESULT hresult, LPCWSTR szError)
|
|
|
|
{
|
|
|
|
if(FAILED(hresult)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Binding failed %08x\n", hresult);
|
2006-06-14 22:35:13 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_status(IDS_INSTALLING);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_GetBindInfo(IBindStatusCallback *iface,
|
|
|
|
DWORD* grfBINDF, BINDINFO* pbindinfo)
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
*grfBINDF = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
|
|
|
|
DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
|
|
|
|
{
|
2010-10-01 15:31:05 +02:00
|
|
|
ERR("\n");
|
|
|
|
return E_NOTIMPL;
|
2006-06-14 22:35:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnObjectAvailable(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, IUnknown* punk)
|
|
|
|
{
|
|
|
|
ERR("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2006-11-29 11:05:31 +01:00
|
|
|
static const IBindStatusCallbackVtbl InstallCallbackVtbl = {
|
2006-06-14 22:35:13 +02:00
|
|
|
InstallCallback_QueryInterface,
|
|
|
|
InstallCallback_AddRef,
|
|
|
|
InstallCallback_Release,
|
|
|
|
InstallCallback_OnStartBinding,
|
|
|
|
InstallCallback_GetPriority,
|
|
|
|
InstallCallback_OnLowResource,
|
|
|
|
InstallCallback_OnProgress,
|
|
|
|
InstallCallback_OnStopBinding,
|
|
|
|
InstallCallback_GetBindInfo,
|
|
|
|
InstallCallback_OnDataAvailable,
|
|
|
|
InstallCallback_OnObjectAvailable
|
|
|
|
};
|
|
|
|
|
|
|
|
static IBindStatusCallback InstallCallback = { &InstallCallbackVtbl };
|
|
|
|
|
|
|
|
static LPWSTR get_url(void)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD res, type;
|
2007-06-06 19:44:20 +02:00
|
|
|
DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR);
|
2009-04-22 21:31:48 +02:00
|
|
|
DWORD returned_size;
|
2006-06-14 22:35:13 +02:00
|
|
|
LPWSTR url;
|
|
|
|
|
|
|
|
static const WCHAR wszGeckoUrl[] = {'G','e','c','k','o','U','r','l',0};
|
2007-06-06 19:44:20 +02:00
|
|
|
static const WCHAR httpW[] = {'h','t','t','p'};
|
2009-12-03 15:08:30 +01:00
|
|
|
static const WCHAR arch_formatW[] = {'?','a','r','c','h','='};
|
|
|
|
static const WCHAR v_formatW[] = {'&','v','='};
|
2006-06-14 22:35:13 +02:00
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\MSHTML */
|
2007-10-10 14:44:07 +02:00
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, mshtml_keyW, &hkey);
|
2006-06-14 22:35:13 +02:00
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
2007-12-05 21:52:31 +01:00
|
|
|
url = heap_alloc(size);
|
2009-04-22 21:31:48 +02:00
|
|
|
returned_size = size;
|
2006-06-14 22:35:13 +02:00
|
|
|
|
2009-04-22 21:31:48 +02:00
|
|
|
res = RegQueryValueExW(hkey, wszGeckoUrl, NULL, &type, (LPBYTE)url, &returned_size);
|
2006-06-14 22:35:13 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS || type != REG_SZ) {
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(url);
|
2006-06-14 22:35:13 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-22 21:31:48 +02:00
|
|
|
if(returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) {
|
2009-12-03 15:08:30 +01:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
len = strlenW(url);
|
|
|
|
memcpy(url+len, arch_formatW, sizeof(arch_formatW));
|
|
|
|
len += sizeof(arch_formatW)/sizeof(WCHAR);
|
|
|
|
len += MultiByteToWideChar(CP_ACP, 0, GECKO_ARCH, sizeof(GECKO_ARCH), url+len, size/sizeof(WCHAR)-len)-1;
|
|
|
|
memcpy(url+len, v_formatW, sizeof(v_formatW));
|
|
|
|
len += sizeof(v_formatW)/sizeof(WCHAR);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, GECKO_VERSION, -1, url+len, size/sizeof(WCHAR)-len);
|
2007-06-06 19:44:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Got URL %s\n", debugstr_w(url));
|
2006-06-14 22:35:13 +02:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI download_proc(PVOID arg)
|
|
|
|
{
|
2010-10-01 15:31:05 +02:00
|
|
|
WCHAR tmp_dir[MAX_PATH], tmp_file[MAX_PATH];
|
2006-06-14 22:35:13 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2010-10-01 15:31:05 +02:00
|
|
|
GetTempPathW(sizeof(tmp_dir)/sizeof(WCHAR), tmp_dir);
|
|
|
|
GetTempFileNameW(tmp_dir, NULL, 0, tmp_file);
|
2006-06-14 22:35:13 +02:00
|
|
|
|
2010-10-01 15:31:05 +02:00
|
|
|
TRACE("using temp file %s\n", debugstr_w(tmp_file));
|
2006-06-14 22:35:13 +02:00
|
|
|
|
2010-10-01 15:31:05 +02:00
|
|
|
hres = URLDownloadToFileW(NULL, url, tmp_file, 0, &InstallCallback);
|
2006-06-14 22:35:13 +02:00
|
|
|
if(FAILED(hres)) {
|
2010-10-01 15:31:05 +02:00
|
|
|
ERR("URLDownloadToFile failed: %08x\n", hres);
|
2006-06-14 22:35:13 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-01 15:31:05 +02:00
|
|
|
install_cab(tmp_file);
|
|
|
|
DeleteFileW(tmp_file);
|
|
|
|
EndDialog(install_dialog, 0);
|
2006-06-14 22:35:13 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK installer_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch(msg) {
|
|
|
|
case WM_INITDIALOG:
|
2007-09-08 01:25:16 +02:00
|
|
|
ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_HIDE);
|
2006-06-14 22:35:13 +02:00
|
|
|
install_dialog = hwnd;
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch(wParam) {
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hwnd, 0);
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case ID_DWL_INSTALL:
|
2007-09-08 01:25:16 +02:00
|
|
|
ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_SHOW);
|
2006-06-14 22:35:13 +02:00
|
|
|
EnableWindow(GetDlgItem(hwnd, ID_DWL_INSTALL), 0);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, IDCANCEL), 0); /* FIXME */
|
|
|
|
CreateThread(NULL, 0, download_proc, NULL, 0, NULL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-14 01:49:19 +02:00
|
|
|
BOOL install_wine_gecko(BOOL silent)
|
2006-06-14 22:35:13 +02:00
|
|
|
{
|
|
|
|
HANDLE hsem;
|
|
|
|
|
2009-12-03 15:08:30 +01:00
|
|
|
if(!*GECKO_ARCH)
|
|
|
|
return FALSE;
|
|
|
|
|
2006-06-14 22:35:13 +02:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
hsem = CreateSemaphoreA( NULL, 0, 1, "mshtml_install_semaphore");
|
|
|
|
|
|
|
|
if(GetLastError() == ERROR_ALREADY_EXISTS) {
|
|
|
|
WaitForSingleObject(hsem, INFINITE);
|
|
|
|
}else {
|
2007-10-10 14:44:07 +02:00
|
|
|
/*
|
|
|
|
* Try to find Gecko .cab file in following order:
|
2010-10-06 21:33:26 +02:00
|
|
|
* - directory stored in GeckoCabDir value of HKCU/Wine/Software/MSHTML key
|
|
|
|
* - $datadir/gecko/
|
|
|
|
* - $GECKO_DATADIR/wine/gecko/
|
|
|
|
* - /usr/share/wine/gecko/
|
|
|
|
* - download from URL stored in GeckoUrl value of HKCU/Wine/Software/MSHTML key
|
2007-10-10 14:44:07 +02:00
|
|
|
*/
|
|
|
|
if(!install_from_registered_dir()
|
|
|
|
&& !install_from_default_dir()
|
2007-10-14 01:49:19 +02:00
|
|
|
&& !silent && (url = get_url()))
|
2007-06-06 19:44:20 +02:00
|
|
|
DialogBoxW(hInst, MAKEINTRESOURCEW(ID_DWL_DIALOG), 0, installer_proc);
|
2006-06-14 22:35:13 +02:00
|
|
|
}
|
|
|
|
|
2010-10-01 15:31:05 +02:00
|
|
|
heap_free(url);
|
|
|
|
url = NULL;
|
2006-06-14 22:35:13 +02:00
|
|
|
ReleaseSemaphore(hsem, 1, NULL);
|
|
|
|
CloseHandle(hsem);
|
2007-02-13 18:06:25 +01:00
|
|
|
|
|
|
|
return TRUE;
|
2006-06-14 22:35:13 +02:00
|
|
|
}
|