Module: wine Branch: refs/heads/master Commit: d1617bea17b8614303ef5b19851e18f25b66a250 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=d1617bea17b8614303ef5b19...
Author: James Hawkins truiken@gmail.com Date: Wed Jul 26 14:54:15 2006 -0700
msi: Download the MSI package if it is a remote URL.
---
dlls/msi/Makefile.in | 2 +- dlls/msi/package.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/Makefile.in b/dlls/msi/Makefile.in index 4bd23e8..fe12586 100644 --- a/dlls/msi/Makefile.in +++ b/dlls/msi/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = msi.dll IMPORTLIB = libmsi.$(IMPLIBEXT) -IMPORTS = comctl32 shell32 shlwapi cabinet oleaut32 ole32 version user32 gdi32 advapi32 kernel32 +IMPORTS = urlmon wininet comctl32 shell32 shlwapi cabinet oleaut32 ole32 version user32 gdi32 advapi32 kernel32 EXTRALIBS = -luuid
C_SRCS = \ diff --git a/dlls/msi/package.c b/dlls/msi/package.c index f3278c1..53433d0 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -35,6 +35,8 @@ #include "msiquery.h" #include "objidl.h" #include "wincrypt.h" #include "winuser.h" +#include "wininet.h" +#include "urlmon.h" #include "shlobj.h" #include "wine/unicode.h" #include "objbase.h" @@ -452,6 +454,38 @@ static LPCWSTR copy_package_to_temp( LPC return filename; }
+static LPCWSTR msi_download_package( LPCWSTR szUrl, LPWSTR filename ) +{ + LPINTERNET_CACHE_ENTRY_INFOW cache_entry; + DWORD size = 0; + HRESULT hr; + + /* call will always fail, becase size is 0, + * but will return ERROR_FILE_NOT_FOUND first + * if the file doesn't exist + */ + GetUrlCacheEntryInfoW( szUrl, NULL, &size ); + if ( GetLastError() != ERROR_FILE_NOT_FOUND ) + { + cache_entry = HeapAlloc( GetProcessHeap(), 0, size ); + if ( !GetUrlCacheEntryInfoW( szUrl, cache_entry, &size ) ) + { + HeapFree( GetProcessHeap(), 0, cache_entry ); + return szUrl; + } + + lstrcpyW( filename, cache_entry->lpszLocalFileName ); + HeapFree( GetProcessHeap(), 0, cache_entry ); + return filename; + } + + hr = URLDownloadToCacheFileW( NULL, szUrl, filename, MAX_PATH, 0, NULL ); + if ( FAILED(hr) ) + return szUrl; + + return filename; +} + UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) { MSIDATABASE *db = NULL; @@ -471,7 +505,12 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, else { WCHAR temppath[MAX_PATH]; - LPCWSTR file = copy_package_to_temp( szPackage, temppath ); + LPCWSTR file; + + if ( UrlIsW( szPackage, URLIS_URL ) ) + file = msi_download_package( szPackage, temppath ); + else + file = copy_package_to_temp( szPackage, temppath );
r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY, &db );