mshtml: Use URLDownloadToFile to download Gecko package file.
This commit is contained in:
parent
1f716bcbf4
commit
a9b4f82c7c
|
@ -63,30 +63,8 @@ static const WCHAR mshtml_keyW[] =
|
||||||
'\\','M','S','H','T','M','L',0};
|
'\\','M','S','H','T','M','L',0};
|
||||||
|
|
||||||
static HWND install_dialog = NULL;
|
static HWND install_dialog = NULL;
|
||||||
static LPWSTR tmp_file_name = NULL;
|
|
||||||
static HANDLE tmp_file = INVALID_HANDLE_VALUE;
|
|
||||||
static LPWSTR url = NULL;
|
static LPWSTR url = NULL;
|
||||||
|
|
||||||
static void clean_up(void)
|
|
||||||
{
|
|
||||||
if(tmp_file != INVALID_HANDLE_VALUE)
|
|
||||||
CloseHandle(tmp_file);
|
|
||||||
|
|
||||||
if(tmp_file_name) {
|
|
||||||
DeleteFileW(tmp_file_name);
|
|
||||||
heap_free(tmp_file_name);
|
|
||||||
tmp_file_name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tmp_file != INVALID_HANDLE_VALUE) {
|
|
||||||
CloseHandle(tmp_file);
|
|
||||||
tmp_file = INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(install_dialog)
|
|
||||||
EndDialog(install_dialog, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_status(DWORD id)
|
static void set_status(DWORD id)
|
||||||
{
|
{
|
||||||
HWND status = GetDlgItem(install_dialog, ID_DWL_STATUS);
|
HWND status = GetDlgItem(install_dialog, ID_DWL_STATUS);
|
||||||
|
@ -174,13 +152,10 @@ static BOOL install_cab(LPCWSTR file_name)
|
||||||
heap_free(file_name_a);
|
heap_free(file_name_a);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
ERR("Could not extract package: %08x\n", hres);
|
ERR("Could not extract package: %08x\n", hres);
|
||||||
clean_up();
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_registry(install_dir);
|
set_registry(install_dir);
|
||||||
clean_up();
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,26 +288,7 @@ static ULONG WINAPI InstallCallback_Release(IBindStatusCallback *iface)
|
||||||
static HRESULT WINAPI InstallCallback_OnStartBinding(IBindStatusCallback *iface,
|
static HRESULT WINAPI InstallCallback_OnStartBinding(IBindStatusCallback *iface,
|
||||||
DWORD dwReserved, IBinding *pib)
|
DWORD dwReserved, IBinding *pib)
|
||||||
{
|
{
|
||||||
WCHAR tmp_dir[MAX_PATH];
|
|
||||||
|
|
||||||
set_status(IDS_DOWNLOADING);
|
set_status(IDS_DOWNLOADING);
|
||||||
|
|
||||||
GetTempPathW(sizeof(tmp_dir)/sizeof(WCHAR), tmp_dir);
|
|
||||||
|
|
||||||
tmp_file_name = heap_alloc(MAX_PATH*sizeof(WCHAR));
|
|
||||||
GetTempFileNameW(tmp_dir, NULL, 0, tmp_file_name);
|
|
||||||
|
|
||||||
TRACE("creating temp file %s\n", debugstr_w(tmp_file_name));
|
|
||||||
|
|
||||||
tmp_file = CreateFileW(tmp_file_name, GENERIC_WRITE, 0, NULL,
|
|
||||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
|
|
||||||
if(tmp_file == INVALID_HANDLE_VALUE) {
|
|
||||||
ERR("Could not create file: %d\n", GetLastError());
|
|
||||||
clean_up();
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,17 +322,10 @@ static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
|
||||||
{
|
{
|
||||||
if(FAILED(hresult)) {
|
if(FAILED(hresult)) {
|
||||||
ERR("Binding failed %08x\n", hresult);
|
ERR("Binding failed %08x\n", hresult);
|
||||||
clean_up();
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(tmp_file);
|
|
||||||
tmp_file = INVALID_HANDLE_VALUE;
|
|
||||||
|
|
||||||
set_status(IDS_INSTALLING);
|
set_status(IDS_INSTALLING);
|
||||||
|
|
||||||
install_cab(tmp_file_name);
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,21 +340,8 @@ static HRESULT WINAPI InstallCallback_GetBindInfo(IBindStatusCallback *iface,
|
||||||
static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
|
static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
|
||||||
DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
|
DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
|
||||||
{
|
{
|
||||||
IStream *str = pstgmed->u.pstm;
|
ERR("\n");
|
||||||
BYTE buf[1024];
|
return E_NOTIMPL;
|
||||||
DWORD size;
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
do {
|
|
||||||
DWORD written;
|
|
||||||
|
|
||||||
size = 0;
|
|
||||||
hres = IStream_Read(str, buf, sizeof(buf), &size);
|
|
||||||
if(size)
|
|
||||||
WriteFile(tmp_file, buf, size, &written, NULL);
|
|
||||||
}while(hres == S_OK);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI InstallCallback_OnObjectAvailable(IBindStatusCallback *iface,
|
static HRESULT WINAPI InstallCallback_OnObjectAvailable(IBindStatusCallback *iface,
|
||||||
|
@ -477,27 +413,23 @@ static LPWSTR get_url(void)
|
||||||
|
|
||||||
static DWORD WINAPI download_proc(PVOID arg)
|
static DWORD WINAPI download_proc(PVOID arg)
|
||||||
{
|
{
|
||||||
IMoniker *mon;
|
WCHAR tmp_dir[MAX_PATH], tmp_file[MAX_PATH];
|
||||||
IBindCtx *bctx;
|
|
||||||
IStream *str = NULL;
|
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
CreateURLMoniker(NULL, url, &mon);
|
GetTempPathW(sizeof(tmp_dir)/sizeof(WCHAR), tmp_dir);
|
||||||
heap_free(url);
|
GetTempFileNameW(tmp_dir, NULL, 0, tmp_file);
|
||||||
url = NULL;
|
|
||||||
|
|
||||||
CreateAsyncBindCtx(0, &InstallCallback, 0, &bctx);
|
TRACE("using temp file %s\n", debugstr_w(tmp_file));
|
||||||
|
|
||||||
hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&str);
|
hres = URLDownloadToFileW(NULL, url, tmp_file, 0, &InstallCallback);
|
||||||
IBindCtx_Release(bctx);
|
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
ERR("BindToStorage failed: %08x\n", hres);
|
ERR("URLDownloadToFile failed: %08x\n", hres);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(str)
|
install_cab(tmp_file);
|
||||||
IStream_Release(str);
|
DeleteFileW(tmp_file);
|
||||||
|
EndDialog(install_dialog, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,6 +484,8 @@ BOOL install_wine_gecko(BOOL silent)
|
||||||
DialogBoxW(hInst, MAKEINTRESOURCEW(ID_DWL_DIALOG), 0, installer_proc);
|
DialogBoxW(hInst, MAKEINTRESOURCEW(ID_DWL_DIALOG), 0, installer_proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heap_free(url);
|
||||||
|
url = NULL;
|
||||||
ReleaseSemaphore(hsem, 1, NULL);
|
ReleaseSemaphore(hsem, 1, NULL);
|
||||||
CloseHandle(hsem);
|
CloseHandle(hsem);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue