2010-12-06 18:25:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2006-2010 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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 <stdarg.h>
|
|
|
|
#include <fcntl.h>
|
2010-12-28 23:53:38 +00:00
|
|
|
#include <stdio.h>
|
2012-10-09 13:48:47 +00:00
|
|
|
#include <errno.h>
|
2010-12-06 18:25:01 +00:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "cpl.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "commctrl.h"
|
|
|
|
#include "advpub.h"
|
|
|
|
#include "wininet.h"
|
2021-06-02 02:54:13 +00:00
|
|
|
#include "pathcch.h"
|
2010-12-06 18:25:01 +00:00
|
|
|
#include "shellapi.h"
|
|
|
|
#include "urlmon.h"
|
2011-02-10 15:42:49 +00:00
|
|
|
#include "msi.h"
|
2017-05-18 02:06:07 +00:00
|
|
|
#include "bcrypt.h"
|
2010-12-06 18:25:01 +00:00
|
|
|
|
|
|
|
#include "appwiz.h"
|
|
|
|
#include "res.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(appwizcpl);
|
|
|
|
|
2023-04-03 14:55:12 +00:00
|
|
|
#define GECKO_VERSION "2.47.4"
|
2010-12-06 18:25:01 +00:00
|
|
|
#ifdef __i386__
|
2020-04-21 22:36:47 +00:00
|
|
|
#define GECKO_ARCH "x86"
|
2023-04-03 14:55:12 +00:00
|
|
|
#define GECKO_SHA "26cecc47706b091908f7f814bddb074c61beb8063318e9efc5a7f789857793d6"
|
2010-12-06 18:25:01 +00:00
|
|
|
#elif defined(__x86_64__)
|
2020-04-21 22:36:47 +00:00
|
|
|
#define GECKO_ARCH "x86_64"
|
2023-04-03 14:55:12 +00:00
|
|
|
#define GECKO_SHA "e590b7d988a32d6aa4cf1d8aa3aa3d33766fdd4cf4c89c2dcc2095ecb28d066f"
|
2010-12-06 18:25:01 +00:00
|
|
|
#else
|
2020-04-21 22:36:47 +00:00
|
|
|
#define GECKO_ARCH ""
|
2010-12-28 23:53:38 +00:00
|
|
|
#define GECKO_SHA "???"
|
2010-12-06 18:25:01 +00:00
|
|
|
#endif
|
|
|
|
|
2023-05-17 16:19:46 +00:00
|
|
|
#define MONO_VERSION "8.0.0"
|
2020-04-19 03:01:17 +00:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
#define MONO_ARCH "x86"
|
2023-05-17 16:19:46 +00:00
|
|
|
#define MONO_SHA "75b3f45dca1dc89857fe9e932da78710f64cc6d49ef1ab0c723a177085b4711b"
|
2020-04-19 03:01:17 +00:00
|
|
|
#else
|
|
|
|
#define MONO_ARCH ""
|
|
|
|
#define MONO_SHA "???"
|
|
|
|
#endif
|
2012-05-21 12:46:03 +00:00
|
|
|
|
2012-05-15 09:47:27 +00:00
|
|
|
typedef struct {
|
2012-05-15 09:47:40 +00:00
|
|
|
const char *version;
|
2019-11-17 14:58:59 +00:00
|
|
|
const WCHAR *file_name;
|
|
|
|
const WCHAR *subdir_name;
|
2012-05-15 09:47:40 +00:00
|
|
|
const char *sha;
|
2012-05-30 11:22:46 +00:00
|
|
|
const char *url_default;
|
2012-05-15 09:48:12 +00:00
|
|
|
const char *config_key;
|
|
|
|
const char *url_config_key;
|
|
|
|
const char *dir_config_key;
|
2012-05-17 14:19:10 +00:00
|
|
|
LPCWSTR dialog_template;
|
2012-05-15 09:47:27 +00:00
|
|
|
} addon_info_t;
|
|
|
|
|
2017-12-13 02:55:37 +00:00
|
|
|
/* Download addon files over HTTP because Wine depends on an external library
|
|
|
|
* for TLS, so we can't be sure that HTTPS will work. The integrity of each file
|
|
|
|
* is checked with a hardcoded cryptographically secure hash. */
|
2012-05-15 09:47:27 +00:00
|
|
|
static const addon_info_t addons_info[] = {
|
|
|
|
{
|
2012-05-15 09:47:40 +00:00
|
|
|
GECKO_VERSION,
|
2020-04-21 22:36:47 +00:00
|
|
|
L"wine-gecko-" GECKO_VERSION "-" GECKO_ARCH ".msi",
|
2019-11-17 14:58:59 +00:00
|
|
|
L"gecko",
|
2012-05-15 09:48:12 +00:00
|
|
|
GECKO_SHA,
|
2012-05-30 11:22:46 +00:00
|
|
|
"http://source.winehq.org/winegecko.php",
|
2012-05-17 14:19:10 +00:00
|
|
|
"MSHTML", "GeckoUrl", "GeckoCabDir",
|
|
|
|
MAKEINTRESOURCEW(ID_DWL_GECKO_DIALOG)
|
2012-05-21 12:46:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
MONO_VERSION,
|
2020-04-19 03:01:17 +00:00
|
|
|
L"wine-mono-" MONO_VERSION "-" MONO_ARCH ".msi",
|
2019-11-17 14:58:59 +00:00
|
|
|
L"mono",
|
2012-05-21 12:46:03 +00:00
|
|
|
MONO_SHA,
|
2012-05-30 11:22:46 +00:00
|
|
|
"http://source.winehq.org/winemono.php",
|
2012-05-21 12:46:03 +00:00
|
|
|
"Dotnet", "MonoUrl", "MonoCabDir",
|
|
|
|
MAKEINTRESOURCEW(ID_DWL_MONO_DIALOG)
|
2012-05-15 09:47:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-05-15 09:48:31 +00:00
|
|
|
static const addon_info_t *addon;
|
2010-12-06 18:25:01 +00:00
|
|
|
|
|
|
|
static HWND install_dialog = NULL;
|
|
|
|
static LPWSTR url = NULL;
|
2013-09-20 14:36:19 +00:00
|
|
|
static IBinding *dwl_binding;
|
2013-09-24 12:04:21 +00:00
|
|
|
static WCHAR *msi_file;
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
extern const char * CDECL wine_get_version(void);
|
|
|
|
|
2012-10-09 13:48:47 +00:00
|
|
|
static WCHAR * (CDECL *p_wine_get_dos_file_name)(const char*);
|
|
|
|
|
2010-12-28 23:53:38 +00:00
|
|
|
static BOOL sha_check(const WCHAR *file_name)
|
|
|
|
{
|
|
|
|
const unsigned char *file_map;
|
|
|
|
HANDLE file, map;
|
|
|
|
DWORD size, i;
|
2017-05-18 02:06:07 +00:00
|
|
|
UCHAR sha[32];
|
|
|
|
char buf[1024];
|
|
|
|
BOOL ret = FALSE;
|
2010-12-28 23:53:38 +00:00
|
|
|
|
2013-09-24 12:04:21 +00:00
|
|
|
file = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
|
|
|
|
if(file == INVALID_HANDLE_VALUE) {
|
2022-02-07 22:10:58 +00:00
|
|
|
WARN("Could not open file: %lu\n", GetLastError());
|
2010-12-28 23:53:38 +00:00
|
|
|
return FALSE;
|
2013-09-24 12:04:21 +00:00
|
|
|
}
|
2010-12-28 23:53:38 +00:00
|
|
|
|
|
|
|
size = GetFileSize(file, NULL);
|
|
|
|
|
|
|
|
map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
if(!map)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
file_map = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
|
|
|
|
CloseHandle(map);
|
|
|
|
if(!file_map)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-09-12 14:14:42 +00:00
|
|
|
if(!BCryptHash(BCRYPT_SHA256_ALG_HANDLE, NULL, 0, (UCHAR *)file_map, size, sha, sizeof(sha))) {
|
|
|
|
for(i=0; i < sizeof(sha); i++)
|
|
|
|
sprintf(buf + i * 2, "%02x", sha[i]);
|
2010-12-28 23:53:38 +00:00
|
|
|
|
2022-09-12 14:14:42 +00:00
|
|
|
ret = !strcmp(buf, addon->sha);
|
|
|
|
if(!ret)
|
|
|
|
WARN("Got %s, expected %s\n", buf, addon->sha);
|
|
|
|
}
|
2010-12-28 23:53:38 +00:00
|
|
|
|
2017-05-18 02:06:07 +00:00
|
|
|
UnmapViewOfFile(file_map);
|
|
|
|
return ret;
|
2010-12-28 23:53:38 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
static void set_status(DWORD id)
|
|
|
|
{
|
|
|
|
HWND status = GetDlgItem(install_dialog, ID_DWL_STATUS);
|
|
|
|
WCHAR buf[64];
|
|
|
|
|
2018-03-29 15:14:13 +00:00
|
|
|
LoadStringW(hInst, id, buf, ARRAY_SIZE(buf));
|
2010-12-06 18:25:01 +00:00
|
|
|
SendMessageW(status, WM_SETTEXT, 0, (LPARAM)buf);
|
|
|
|
}
|
|
|
|
|
2012-07-16 08:09:32 +00:00
|
|
|
enum install_res {
|
|
|
|
INSTALL_OK = 0,
|
|
|
|
INSTALL_FAILED,
|
|
|
|
INSTALL_NEXT,
|
|
|
|
};
|
|
|
|
|
|
|
|
static enum install_res install_file(const WCHAR *file_name)
|
2011-02-10 15:42:49 +00:00
|
|
|
{
|
|
|
|
ULONG res;
|
|
|
|
|
|
|
|
res = MsiInstallProductW(file_name, NULL);
|
2018-06-21 20:58:29 +00:00
|
|
|
if(res == ERROR_PRODUCT_VERSION)
|
2020-11-01 22:31:58 +00:00
|
|
|
res = MsiInstallProductW(file_name, L"REINSTALL=ALL REINSTALLMODE=vomus");
|
2011-02-10 15:42:49 +00:00
|
|
|
if(res != ERROR_SUCCESS) {
|
2022-02-07 22:10:58 +00:00
|
|
|
ERR("MsiInstallProduct failed: %lu\n", res);
|
2012-07-16 08:09:32 +00:00
|
|
|
return INSTALL_FAILED;
|
2011-02-10 15:42:49 +00:00
|
|
|
}
|
|
|
|
|
2012-07-16 08:09:32 +00:00
|
|
|
return INSTALL_OK;
|
2011-02-10 15:42:49 +00:00
|
|
|
}
|
|
|
|
|
2019-11-17 14:58:59 +00:00
|
|
|
static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *subdir, const WCHAR *file_name)
|
2010-12-06 18:25:01 +00:00
|
|
|
{
|
2021-06-02 02:54:13 +00:00
|
|
|
WCHAR *path, *canonical_path;
|
2012-07-16 08:09:32 +00:00
|
|
|
enum install_res ret;
|
2019-07-05 09:12:36 +00:00
|
|
|
int len = lstrlenW( dir );
|
|
|
|
int size = len + 1;
|
2021-06-02 02:54:13 +00:00
|
|
|
HRESULT hr;
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2019-11-17 14:58:59 +00:00
|
|
|
size += lstrlenW( subdir ) + lstrlenW( file_name ) + 2;
|
2022-11-21 01:58:20 +00:00
|
|
|
if (!(path = malloc( size * sizeof(WCHAR) ))) return INSTALL_FAILED;
|
2012-05-15 09:47:27 +00:00
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
lstrcpyW( path, dir );
|
2019-11-17 14:58:59 +00:00
|
|
|
if (!wcsncmp( path, L"\\??\\", 4 )) path[1] = '\\'; /* change \??\ into \\?\ */
|
2019-07-05 09:12:36 +00:00
|
|
|
if (len && path[len-1] != '/' && path[len-1] != '\\') path[len++] = '\\';
|
|
|
|
|
2019-11-17 14:58:59 +00:00
|
|
|
lstrcpyW( path + len, subdir );
|
|
|
|
lstrcatW( path, L"\\" );
|
|
|
|
lstrcatW( path, file_name );
|
2012-05-15 09:47:27 +00:00
|
|
|
|
2021-06-02 02:54:13 +00:00
|
|
|
hr = PathAllocCanonicalize( path, PATHCCH_ALLOW_LONG_PATHS, &canonical_path );
|
|
|
|
if (FAILED( hr ))
|
2019-07-05 09:12:36 +00:00
|
|
|
{
|
2022-02-07 22:10:58 +00:00
|
|
|
ERR( "Failed to canonicalize %s, hr %#lx\n", debugstr_w(path), hr );
|
2022-11-21 01:58:20 +00:00
|
|
|
free( path );
|
2012-07-16 08:09:32 +00:00
|
|
|
return INSTALL_NEXT;
|
2010-12-06 18:25:01 +00:00
|
|
|
}
|
2022-11-21 01:58:20 +00:00
|
|
|
free( path );
|
2021-06-02 02:54:13 +00:00
|
|
|
|
|
|
|
if (GetFileAttributesW( canonical_path ) == INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
TRACE( "%s not found\n", debugstr_w(canonical_path) );
|
|
|
|
LocalFree( canonical_path );
|
|
|
|
return INSTALL_NEXT;
|
|
|
|
}
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2021-06-02 02:54:13 +00:00
|
|
|
ret = install_file( canonical_path );
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2021-06-02 02:54:13 +00:00
|
|
|
LocalFree( canonical_path );
|
2019-07-05 09:12:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-15 09:47:27 +00:00
|
|
|
|
2019-11-17 14:58:59 +00:00
|
|
|
static enum install_res install_from_unix_file(const char *dir, const WCHAR *subdir, const WCHAR *file_name)
|
2019-07-05 09:12:36 +00:00
|
|
|
{
|
|
|
|
WCHAR *dos_dir;
|
|
|
|
enum install_res ret = INSTALL_NEXT;
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
if (p_wine_get_dos_file_name && (dos_dir = p_wine_get_dos_file_name( dir )))
|
|
|
|
{
|
|
|
|
ret = install_from_dos_file( dos_dir, subdir, file_name );
|
2022-11-25 15:11:25 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, dos_dir );
|
2019-07-05 09:12:36 +00:00
|
|
|
}
|
2010-12-06 18:25:01 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-05-15 09:48:12 +00:00
|
|
|
static HKEY open_config_key(void)
|
|
|
|
{
|
|
|
|
HKEY hkey, ret;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\$config_key */
|
2020-11-01 22:31:58 +00:00
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Wine", &hkey);
|
2012-05-15 09:48:12 +00:00
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
res = RegOpenKeyA(hkey, addon->config_key, &ret);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return res == ERROR_SUCCESS ? ret : NULL;
|
|
|
|
}
|
|
|
|
|
2012-07-16 08:09:32 +00:00
|
|
|
static enum install_res install_from_registered_dir(void)
|
2010-12-06 18:25:01 +00:00
|
|
|
{
|
2022-11-29 05:05:13 +00:00
|
|
|
char *package_dir, *new_package_dir;
|
2010-12-06 18:25:01 +00:00
|
|
|
HKEY hkey;
|
|
|
|
DWORD res, type, size = MAX_PATH;
|
2012-07-16 08:09:32 +00:00
|
|
|
enum install_res ret;
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2012-05-15 09:48:12 +00:00
|
|
|
hkey = open_config_key();
|
|
|
|
if(!hkey)
|
2012-07-16 08:09:32 +00:00
|
|
|
return INSTALL_NEXT;
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2022-11-21 01:58:20 +00:00
|
|
|
package_dir = malloc(size);
|
2012-05-15 09:48:12 +00:00
|
|
|
res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size);
|
2010-12-06 18:25:01 +00:00
|
|
|
if(res == ERROR_MORE_DATA) {
|
2022-11-29 05:05:13 +00:00
|
|
|
new_package_dir = realloc(package_dir, size);
|
|
|
|
if(new_package_dir) {
|
|
|
|
package_dir = new_package_dir;
|
|
|
|
res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size);
|
|
|
|
}
|
2010-12-06 18:25:01 +00:00
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
2012-07-16 08:09:32 +00:00
|
|
|
if(res == ERROR_FILE_NOT_FOUND) {
|
2022-11-21 01:58:20 +00:00
|
|
|
free(package_dir);
|
2012-07-16 08:09:32 +00:00
|
|
|
return INSTALL_NEXT;
|
|
|
|
} else if(res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ)) {
|
2022-11-21 01:58:20 +00:00
|
|
|
free(package_dir);
|
2012-07-16 08:09:32 +00:00
|
|
|
return INSTALL_FAILED;
|
2010-12-06 18:25:01 +00:00
|
|
|
}
|
|
|
|
|
2019-11-17 14:58:59 +00:00
|
|
|
ret = install_from_unix_file(package_dir, L"", addon->file_name);
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2022-11-21 01:58:20 +00:00
|
|
|
free(package_dir);
|
2010-12-06 18:25:01 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-07-16 08:09:32 +00:00
|
|
|
static enum install_res install_from_default_dir(void)
|
2010-12-06 18:25:01 +00:00
|
|
|
{
|
2019-07-05 09:12:36 +00:00
|
|
|
const WCHAR *package_dir;
|
|
|
|
WCHAR *dir_buf = NULL;
|
|
|
|
enum install_res ret = INSTALL_NEXT;
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2020-11-01 22:31:58 +00:00
|
|
|
if ((package_dir = _wgetenv( L"WINEBUILDDIR" )))
|
2019-07-05 09:12:36 +00:00
|
|
|
{
|
2022-11-21 01:58:20 +00:00
|
|
|
dir_buf = malloc( wcslen(package_dir) * sizeof(WCHAR) + sizeof(L"\\..\\") );
|
2019-07-05 09:12:36 +00:00
|
|
|
lstrcpyW( dir_buf, package_dir );
|
2020-11-01 22:31:58 +00:00
|
|
|
lstrcatW( dir_buf, L"\\..\\" );
|
2012-05-15 09:47:58 +00:00
|
|
|
package_dir = dir_buf;
|
|
|
|
}
|
2020-11-01 22:31:58 +00:00
|
|
|
else package_dir = _wgetenv( L"WINEDATADIR" );
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
if (package_dir)
|
|
|
|
{
|
|
|
|
ret = install_from_dos_file(package_dir, addon->subdir_name, addon->file_name);
|
2022-11-21 01:58:20 +00:00
|
|
|
free(dir_buf);
|
2019-07-05 09:12:36 +00:00
|
|
|
}
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2012-07-16 08:09:32 +00:00
|
|
|
if (ret == INSTALL_NEXT)
|
2012-05-15 09:47:58 +00:00
|
|
|
ret = install_from_unix_file(INSTALL_DATADIR "/wine/", addon->subdir_name, addon->file_name);
|
2020-04-20 12:40:11 +00:00
|
|
|
if (ret == INSTALL_NEXT && strcmp(INSTALL_DATADIR, "/usr/share") != 0)
|
2012-05-15 09:47:58 +00:00
|
|
|
ret = install_from_unix_file("/usr/share/wine/", addon->subdir_name, addon->file_name);
|
2019-03-21 15:14:39 +00:00
|
|
|
if (ret == INSTALL_NEXT)
|
|
|
|
ret = install_from_unix_file("/opt/wine/", addon->subdir_name, addon->file_name);
|
2010-12-06 18:25:01 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-10-09 13:48:47 +00:00
|
|
|
static WCHAR *get_cache_file_name(BOOL ensure_exists)
|
|
|
|
{
|
2019-07-05 09:12:36 +00:00
|
|
|
const char *xdg_dir;
|
|
|
|
const WCHAR *home_dir;
|
|
|
|
WCHAR *cache_dir, *ret;
|
|
|
|
size_t len, size;
|
|
|
|
|
|
|
|
xdg_dir = getenv( "XDG_CACHE_HOME" );
|
|
|
|
if (xdg_dir && *xdg_dir && p_wine_get_dos_file_name)
|
|
|
|
{
|
|
|
|
if (!(cache_dir = p_wine_get_dos_file_name( xdg_dir ))) return NULL;
|
2012-10-09 13:48:47 +00:00
|
|
|
}
|
2020-11-01 22:31:58 +00:00
|
|
|
else if ((home_dir = _wgetenv( L"WINEHOMEDIR" )))
|
2019-07-05 09:12:36 +00:00
|
|
|
{
|
2022-11-25 15:11:25 +00:00
|
|
|
if (!(cache_dir = HeapAlloc( GetProcessHeap(), 0, wcslen(home_dir) * sizeof(WCHAR) + sizeof(L"\\.cache") ))) return NULL;
|
2019-07-05 09:12:36 +00:00
|
|
|
lstrcpyW( cache_dir, home_dir );
|
2020-11-01 22:31:58 +00:00
|
|
|
lstrcatW( cache_dir, L"\\.cache" );
|
2019-07-05 09:12:36 +00:00
|
|
|
cache_dir[1] = '\\'; /* change \??\ into \\?\ */
|
|
|
|
}
|
|
|
|
else return NULL;
|
2012-10-09 13:48:47 +00:00
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
if (ensure_exists && !CreateDirectoryW( cache_dir, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
2022-02-07 22:10:58 +00:00
|
|
|
WARN( "%s does not exist and could not be created (%lu)\n", debugstr_w(cache_dir), GetLastError() );
|
2022-11-25 15:11:25 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, cache_dir );
|
2012-10-09 13:48:47 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-01 22:31:58 +00:00
|
|
|
size = lstrlenW( cache_dir ) + ARRAY_SIZE(L"\\wine") + lstrlenW( addon->file_name ) + 1;
|
2022-11-21 01:58:20 +00:00
|
|
|
if (!(ret = malloc( size * sizeof(WCHAR) )))
|
2019-07-05 09:12:36 +00:00
|
|
|
{
|
2022-11-25 15:11:25 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, cache_dir );
|
2012-10-09 13:48:47 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-07-05 09:12:36 +00:00
|
|
|
lstrcpyW( ret, cache_dir );
|
2020-11-01 22:31:58 +00:00
|
|
|
lstrcatW( ret, L"\\wine" );
|
2022-11-25 15:11:25 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, cache_dir );
|
2012-10-09 13:48:47 +00:00
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
if (ensure_exists && !CreateDirectoryW( ret, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
2022-02-07 22:10:58 +00:00
|
|
|
WARN( "%s does not exist and could not be created (%lu)\n", debugstr_w(ret), GetLastError() );
|
2022-11-21 01:58:20 +00:00
|
|
|
free( ret );
|
2012-10-09 13:48:47 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-07-05 09:12:36 +00:00
|
|
|
len = lstrlenW( ret );
|
|
|
|
ret[len++] = '\\';
|
2019-11-17 14:58:59 +00:00
|
|
|
lstrcpyW( ret + len, addon->file_name );
|
2012-10-09 13:48:47 +00:00
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
TRACE( "got %s\n", debugstr_w(ret) );
|
2012-10-09 13:48:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum install_res install_from_cache(void)
|
|
|
|
{
|
|
|
|
WCHAR *cache_file_name;
|
|
|
|
enum install_res res;
|
|
|
|
|
|
|
|
cache_file_name = get_cache_file_name(FALSE);
|
|
|
|
if(!cache_file_name)
|
|
|
|
return INSTALL_NEXT;
|
|
|
|
|
|
|
|
if(!sha_check(cache_file_name)) {
|
2015-11-26 22:23:09 +00:00
|
|
|
WARN("could not validate checksum\n");
|
2012-10-09 13:48:47 +00:00
|
|
|
DeleteFileW(cache_file_name);
|
2022-11-21 01:58:20 +00:00
|
|
|
free(cache_file_name);
|
2012-10-09 13:48:47 +00:00
|
|
|
return INSTALL_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = install_file(cache_file_name);
|
2022-11-21 01:58:20 +00:00
|
|
|
free(cache_file_name);
|
2012-10-09 13:48:47 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-02-25 18:35:12 +00:00
|
|
|
static IInternetBindInfo InstallCallbackBindInfo;
|
|
|
|
|
2010-12-06 18:25:01 +00: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;
|
|
|
|
}
|
|
|
|
|
2015-02-25 18:35:12 +00:00
|
|
|
if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
TRACE("IID_IInternetBindInfo\n");
|
|
|
|
*ppv = &InstallCallbackBindInfo;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
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);
|
2013-09-20 14:36:19 +00:00
|
|
|
|
|
|
|
IBinding_AddRef(pib);
|
|
|
|
dwl_binding = pib;
|
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-09-20 14:36:19 +00:00
|
|
|
if(dwl_binding) {
|
|
|
|
IBinding_Release(dwl_binding);
|
|
|
|
dwl_binding = NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
if(FAILED(hresult)) {
|
2013-09-20 14:36:19 +00:00
|
|
|
if(hresult == E_ABORT)
|
|
|
|
TRACE("Binding aborted\n");
|
|
|
|
else
|
2022-02-07 22:10:58 +00:00
|
|
|
ERR("Binding failed %08lx\n", hresult);
|
2010-12-06 18:25:01 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-24 12:04:21 +00:00
|
|
|
if(!msi_file) {
|
|
|
|
ERR("No MSI file\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
set_status(IDS_INSTALLING);
|
2013-09-24 12:04:21 +00:00
|
|
|
EnableWindow(GetDlgItem(install_dialog, IDCANCEL), 0);
|
|
|
|
|
|
|
|
if(sha_check(msi_file)) {
|
|
|
|
WCHAR *cache_file_name;
|
|
|
|
|
|
|
|
install_file(msi_file);
|
|
|
|
|
|
|
|
cache_file_name = get_cache_file_name(TRUE);
|
|
|
|
if(cache_file_name) {
|
2018-12-26 19:43:03 +00:00
|
|
|
CopyFileW(msi_file, cache_file_name, FALSE);
|
2022-11-21 01:58:20 +00:00
|
|
|
free(cache_file_name);
|
2013-09-24 12:04:21 +00:00
|
|
|
}
|
|
|
|
}else {
|
|
|
|
WCHAR message[256];
|
|
|
|
|
2018-03-29 15:14:13 +00:00
|
|
|
if(LoadStringW(hInst, IDS_INVALID_SHA, message, ARRAY_SIZE(message)))
|
2013-09-24 12:04:21 +00:00
|
|
|
MessageBoxW(NULL, message, NULL, MB_ICONERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteFileW(msi_file);
|
2022-11-21 01:58:20 +00:00
|
|
|
free(msi_file);
|
2013-09-24 12:04:21 +00:00
|
|
|
msi_file = NULL;
|
|
|
|
|
|
|
|
EndDialog(install_dialog, 0);
|
2010-12-06 18:25:01 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_GetBindInfo(IBindStatusCallback *iface,
|
|
|
|
DWORD* grfBINDF, BINDINFO* pbindinfo)
|
|
|
|
{
|
2013-09-24 12:04:21 +00:00
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
*grfBINDF = BINDF_ASYNCHRONOUS;
|
2010-12-06 18:25:01 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
|
|
|
|
DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
|
|
|
|
{
|
2013-09-24 12:04:21 +00:00
|
|
|
if(!msi_file) {
|
2023-07-12 13:45:55 +00:00
|
|
|
msi_file = wcsdup(pstgmed->lpszFileName);
|
2013-09-24 12:04:21 +00:00
|
|
|
TRACE("got file name %s\n", debugstr_w(msi_file));
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2010-12-06 18:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallback_OnObjectAvailable(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, IUnknown* punk)
|
|
|
|
{
|
|
|
|
ERR("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindStatusCallbackVtbl InstallCallbackVtbl = {
|
|
|
|
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 };
|
|
|
|
|
2015-02-25 18:35:12 +00:00
|
|
|
static HRESULT WINAPI InstallCallbackBindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
return IBindStatusCallback_QueryInterface(&InstallCallback, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InstallCallbackBindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InstallCallbackBindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallbackBindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *bindf, BINDINFO *bindinfo)
|
|
|
|
{
|
|
|
|
ERR("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InstallCallbackBindInfo_GetBindString(IInternetBindInfo *iface, ULONG string_type,
|
|
|
|
WCHAR **strs, ULONG cnt, ULONG *fetched)
|
|
|
|
{
|
|
|
|
switch(string_type) {
|
|
|
|
case BINDSTRING_USER_AGENT:
|
|
|
|
TRACE("BINDSTRING_USER_AGENT\n");
|
|
|
|
|
2020-11-01 22:31:58 +00:00
|
|
|
*strs = CoTaskMemAlloc(sizeof(L"Wine Addon Downloader"));
|
2015-02-25 18:35:12 +00:00
|
|
|
if(!*strs)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2020-11-01 22:31:58 +00:00
|
|
|
lstrcpyW(*strs, L"Wine Addon Downloader");
|
2015-02-25 18:35:12 +00:00
|
|
|
*fetched = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetBindInfoVtbl InstallCallbackBindInfoVtbl = {
|
|
|
|
InstallCallbackBindInfo_QueryInterface,
|
|
|
|
InstallCallbackBindInfo_AddRef,
|
|
|
|
InstallCallbackBindInfo_Release,
|
|
|
|
InstallCallbackBindInfo_GetBindInfo,
|
|
|
|
InstallCallbackBindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
|
|
|
static IInternetBindInfo InstallCallbackBindInfo = { &InstallCallbackBindInfoVtbl };
|
|
|
|
|
2012-05-30 11:22:46 +00:00
|
|
|
static void append_url_params( WCHAR *url )
|
|
|
|
{
|
|
|
|
DWORD size = INTERNET_MAX_URL_LENGTH * sizeof(WCHAR);
|
2019-07-05 09:12:36 +00:00
|
|
|
DWORD len = lstrlenW(url);
|
2012-05-30 11:22:46 +00:00
|
|
|
|
2020-11-01 22:31:59 +00:00
|
|
|
lstrcpyW(url+len, L"?arch=");
|
|
|
|
len += lstrlenW(L"?arch=");
|
2020-04-21 22:36:47 +00:00
|
|
|
len += MultiByteToWideChar(CP_ACP, 0, GECKO_ARCH, sizeof(GECKO_ARCH),
|
2012-05-30 11:22:46 +00:00
|
|
|
url+len, size/sizeof(WCHAR)-len)-1;
|
2020-11-01 22:31:59 +00:00
|
|
|
lstrcpyW(url+len, L"&v=");
|
|
|
|
len += lstrlenW(L"&v=");
|
2015-03-04 11:45:13 +00:00
|
|
|
len += MultiByteToWideChar(CP_ACP, 0, addon->version, -1, url+len, size/sizeof(WCHAR)-len)-1;
|
2020-11-01 22:31:59 +00:00
|
|
|
lstrcpyW(url+len, L"&winev=");
|
|
|
|
len += lstrlenW(L"&winev=");
|
2019-07-05 09:12:36 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, wine_get_version(), -1, url+len, size/sizeof(WCHAR)-len);
|
2012-05-30 11:22:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
static LPWSTR get_url(void)
|
|
|
|
{
|
2012-05-15 09:48:12 +00:00
|
|
|
DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR);
|
|
|
|
WCHAR *url, *config_key;
|
2010-12-06 18:25:01 +00:00
|
|
|
HKEY hkey;
|
|
|
|
DWORD res, type;
|
|
|
|
DWORD returned_size;
|
|
|
|
|
|
|
|
static const WCHAR httpW[] = {'h','t','t','p'};
|
|
|
|
|
2022-11-21 01:58:20 +00:00
|
|
|
url = malloc(size);
|
2010-12-06 18:25:01 +00:00
|
|
|
returned_size = size;
|
|
|
|
|
2012-05-30 11:22:46 +00:00
|
|
|
hkey = open_config_key();
|
|
|
|
if (hkey)
|
|
|
|
{
|
2022-11-21 01:58:20 +00:00
|
|
|
config_key = strdupAtoW(addon->url_config_key);
|
2012-05-30 11:22:46 +00:00
|
|
|
res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size);
|
2022-11-21 01:58:20 +00:00
|
|
|
free(config_key);
|
2012-05-30 11:22:46 +00:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res == ERROR_SUCCESS && type == REG_SZ) goto found;
|
2010-12-06 18:25:01 +00:00
|
|
|
}
|
|
|
|
|
2012-05-30 11:22:46 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, addon->url_default, -1, url, size / sizeof(WCHAR) );
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2012-05-30 11:22:46 +00:00
|
|
|
found:
|
|
|
|
if (returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) append_url_params( url );
|
2010-12-06 18:25:01 +00:00
|
|
|
|
|
|
|
TRACE("Got URL %s\n", debugstr_w(url));
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2013-09-24 12:04:21 +00:00
|
|
|
static BOOL start_download(void)
|
2010-12-06 18:25:01 +00:00
|
|
|
{
|
2013-09-24 12:04:21 +00:00
|
|
|
IBindCtx *bind_ctx;
|
|
|
|
IMoniker *mon;
|
|
|
|
IUnknown *tmp;
|
2010-12-06 18:25:01 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
2013-09-24 12:04:21 +00:00
|
|
|
hres = CreateURLMoniker(NULL, url, &mon);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return FALSE;
|
2012-10-09 13:48:47 +00:00
|
|
|
|
2013-09-24 12:04:21 +00:00
|
|
|
hres = CreateAsyncBindCtx(0, &InstallCallback, NULL, &bind_ctx);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IMoniker_BindToStorage(mon, bind_ctx, NULL, &IID_IUnknown, (void**)&tmp);
|
|
|
|
IBindCtx_Release(bind_ctx);
|
2012-10-09 13:48:47 +00:00
|
|
|
}
|
2013-09-24 12:04:21 +00:00
|
|
|
IMoniker_Release(mon);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return FALSE;
|
2012-10-09 13:48:47 +00:00
|
|
|
|
2013-09-24 12:04:21 +00:00
|
|
|
if(tmp)
|
|
|
|
IUnknown_Release(tmp);
|
|
|
|
return TRUE;
|
2010-12-06 18:25:01 +00:00
|
|
|
}
|
|
|
|
|
2011-12-07 17:28:04 +00:00
|
|
|
static void run_winebrowser(const WCHAR *url)
|
2010-12-06 18:25:01 +00:00
|
|
|
{
|
2011-12-07 17:28:04 +00:00
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFOW si;
|
|
|
|
WCHAR app[MAX_PATH];
|
|
|
|
LONG len, url_len;
|
|
|
|
WCHAR *args;
|
|
|
|
BOOL ret;
|
|
|
|
|
2019-07-05 09:12:36 +00:00
|
|
|
url_len = lstrlenW(url);
|
2011-12-07 17:28:04 +00:00
|
|
|
|
2020-11-01 22:31:58 +00:00
|
|
|
len = GetSystemDirectoryW(app, MAX_PATH - ARRAY_SIZE(L"\\winebrowser.exe"));
|
|
|
|
lstrcpyW(app+len, L"\\winebrowser.exe");
|
|
|
|
len += ARRAY_SIZE(L"\\winebrowser.exe") - 1;
|
2011-12-07 17:28:04 +00:00
|
|
|
|
2022-11-21 01:58:20 +00:00
|
|
|
args = malloc((len + 1 + url_len) * sizeof(WCHAR));
|
2011-12-07 17:28:04 +00:00
|
|
|
if(!args)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memcpy(args, app, len*sizeof(WCHAR));
|
|
|
|
args[len++] = ' ';
|
|
|
|
memcpy(args+len, url, (url_len+1) * sizeof(WCHAR));
|
2011-12-01 19:37:18 +00:00
|
|
|
|
2011-12-07 17:28:04 +00:00
|
|
|
TRACE("starting %s\n", debugstr_w(args));
|
|
|
|
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
|
|
si.cb = sizeof(si);
|
2013-01-14 20:20:06 +00:00
|
|
|
ret = CreateProcessW(app, args, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi);
|
2022-11-21 01:58:20 +00:00
|
|
|
free(args);
|
2011-12-07 17:28:04 +00:00
|
|
|
if (ret) {
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK installer_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2010-12-06 18:25:01 +00:00
|
|
|
switch(msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_HIDE);
|
|
|
|
install_dialog = hwnd;
|
|
|
|
return TRUE;
|
|
|
|
|
2011-12-01 19:37:18 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((NMHDR *)lParam)->code)
|
|
|
|
{
|
|
|
|
case NM_CLICK:
|
|
|
|
case NM_RETURN:
|
|
|
|
if (wParam == ID_DWL_STATUS)
|
2011-12-07 17:28:04 +00:00
|
|
|
run_winebrowser(((NMLINK*)lParam)->item.szUrl);
|
2011-12-01 19:37:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch(wParam) {
|
|
|
|
case IDCANCEL:
|
2013-09-20 14:36:19 +00:00
|
|
|
if(dwl_binding)
|
|
|
|
IBinding_Abort(dwl_binding);
|
2010-12-06 18:25:01 +00:00
|
|
|
EndDialog(hwnd, 0);
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case ID_DWL_INSTALL:
|
|
|
|
ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_SHOW);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, ID_DWL_INSTALL), 0);
|
2013-09-24 12:04:21 +00:00
|
|
|
if(!start_download())
|
|
|
|
EndDialog(install_dialog, 0);
|
2010-12-06 18:25:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-05-15 09:48:31 +00:00
|
|
|
BOOL install_addon(addon_t addon_type)
|
2010-12-06 18:25:01 +00:00
|
|
|
{
|
2020-04-21 22:36:47 +00:00
|
|
|
if(!*GECKO_ARCH)
|
2010-12-06 18:25:01 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-05-15 09:48:31 +00:00
|
|
|
addon = addons_info+addon_type;
|
|
|
|
|
2020-11-01 22:31:58 +00:00
|
|
|
p_wine_get_dos_file_name = (void *)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "wine_get_dos_file_name");
|
2012-10-09 13:48:47 +00:00
|
|
|
|
2010-12-06 18:25:01 +00:00
|
|
|
/*
|
2012-05-15 09:48:31 +00:00
|
|
|
* Try to find addon .msi file in following order:
|
2014-09-24 14:29:01 +00:00
|
|
|
* - directory stored in $dir_config_key value of HKCU/Software/Wine/$config_key key
|
2012-05-15 09:48:31 +00:00
|
|
|
* - $datadir/$addon_subdir/
|
|
|
|
* - $INSTALL_DATADIR/wine/$addon_subdir/
|
|
|
|
* - /usr/share/wine/$addon_subdir/
|
2019-03-21 15:14:39 +00:00
|
|
|
* - /opt/wine/$addon_subdir/
|
2014-09-24 14:29:01 +00:00
|
|
|
* - download from URL stored in $url_config_key value of HKCU/Software/Wine/$config_key key
|
2010-12-06 18:25:01 +00:00
|
|
|
*/
|
2012-07-16 08:09:32 +00:00
|
|
|
if (install_from_registered_dir() == INSTALL_NEXT
|
|
|
|
&& install_from_default_dir() == INSTALL_NEXT
|
2012-10-09 13:48:47 +00:00
|
|
|
&& install_from_cache() == INSTALL_NEXT
|
2012-07-16 08:09:32 +00:00
|
|
|
&& (url = get_url()))
|
2012-05-17 14:19:10 +00:00
|
|
|
DialogBoxW(hInst, addon->dialog_template, 0, installer_proc);
|
2010-12-06 18:25:01 +00:00
|
|
|
|
2022-11-21 01:58:20 +00:00
|
|
|
free(url);
|
2010-12-06 18:25:01 +00:00
|
|
|
url = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|