2005-06-16 22:40:34 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-06-16 22:40:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Msi top level apis directly related to installs */
|
|
|
|
|
2007-07-04 04:14:37 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msi.h"
|
|
|
|
#include "msidefs.h"
|
2007-07-06 02:48:08 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "oleauto.h"
|
2007-07-04 04:14:37 +02:00
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
#include "msipriv.h"
|
2007-07-04 04:14:37 +02:00
|
|
|
#include "msiserver.h"
|
2006-07-18 11:43:33 +02:00
|
|
|
#include "wine/unicode.h"
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiDoActionA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction )
|
|
|
|
{
|
|
|
|
LPWSTR szwAction;
|
2005-09-13 12:37:46 +02:00
|
|
|
UINT ret;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 12:37:46 +02:00
|
|
|
TRACE("%s\n", debugstr_a(szAction));
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
szwAction = strdupAtoW(szAction);
|
2005-09-13 12:37:46 +02:00
|
|
|
if (szAction && !szwAction)
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-09-13 12:37:46 +02:00
|
|
|
ret = MsiDoActionW( hInstall, szwAction );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwAction );
|
2005-09-13 12:37:46 +02:00
|
|
|
return ret;
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiDoActionW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
2005-09-13 12:37:46 +02:00
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%s\n",debugstr_w(szAction));
|
|
|
|
|
|
|
|
if (!szAction)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 12:37:46 +02:00
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
|
|
|
if (!package)
|
2007-07-04 04:14:37 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR action;
|
2007-07-04 04:14:37 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
action = SysAllocString( szAction );
|
|
|
|
if (!action)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
2007-07-04 04:14:37 +02:00
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
hr = IWineMsiRemotePackage_DoAction( remote_package, action );
|
|
|
|
|
|
|
|
SysFreeString( action );
|
2007-07-04 04:14:37 +02:00
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-09-13 12:37:46 +02:00
|
|
|
|
2007-06-25 21:47:38 +02:00
|
|
|
ret = ACTION_PerformUIAction( package, szAction, -1 );
|
2005-09-13 12:37:46 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-09-20 13:37:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiSequenceA (MSI.@)
|
|
|
|
*/
|
2005-09-21 12:55:23 +02:00
|
|
|
UINT WINAPI MsiSequenceA( MSIHANDLE hInstall, LPCSTR szTable, INT iSequenceMode )
|
2005-09-20 13:37:30 +02:00
|
|
|
{
|
2005-09-21 12:55:23 +02:00
|
|
|
LPWSTR szwTable;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_a(szTable));
|
|
|
|
|
|
|
|
szwTable = strdupAtoW(szTable);
|
|
|
|
if (szTable && !szwTable)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
ret = MsiSequenceW( hInstall, szwTable, iSequenceMode );
|
|
|
|
msi_free( szwTable );
|
|
|
|
return ret;
|
2005-09-20 13:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiSequenceW (MSI.@)
|
|
|
|
*/
|
2005-09-21 12:55:23 +02:00
|
|
|
UINT WINAPI MsiSequenceW( MSIHANDLE hInstall, LPCWSTR szTable, INT iSequenceMode )
|
2005-09-20 13:37:30 +02:00
|
|
|
{
|
2005-09-21 12:55:23 +02:00
|
|
|
MSIPACKAGE *package;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(szTable));
|
|
|
|
|
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
|
|
|
if (!package)
|
2007-07-04 04:15:06 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR table;
|
2007-07-04 04:15:06 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
table = SysAllocString( szTable );
|
|
|
|
if (!table)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_Sequence( remote_package, table, iSequenceMode );
|
2007-07-04 04:15:06 +02:00
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString( table );
|
2007-07-04 04:15:06 +02:00
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-09-21 12:55:23 +02:00
|
|
|
|
|
|
|
ret = MSI_Sequence( package, szTable, iSequenceMode );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
|
|
|
|
return ret;
|
2005-09-20 13:37:30 +02:00
|
|
|
}
|
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz )
|
2005-09-13 13:25:20 +02:00
|
|
|
{
|
|
|
|
UINT len, r = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
if (awbuf->str.w && !sz )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!sz)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
if (awbuf->unicode)
|
|
|
|
{
|
|
|
|
len = lstrlenW( str );
|
|
|
|
if (awbuf->str.w)
|
|
|
|
lstrcpynW( awbuf->str.w, str, *sz );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-31 15:07:37 +01:00
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
|
|
|
|
if (len)
|
|
|
|
len--;
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, str, -1, awbuf->str.a, *sz, NULL, NULL );
|
2006-09-26 05:03:31 +02:00
|
|
|
if ( awbuf->str.a && *sz && (len >= *sz) )
|
2005-10-31 15:07:37 +01:00
|
|
|
awbuf->str.a[*sz - 1] = 0;
|
2005-09-13 13:25:20 +02:00
|
|
|
}
|
|
|
|
|
2005-11-15 17:53:47 +01:00
|
|
|
if (awbuf->str.w && len >= *sz)
|
2005-09-13 13:25:20 +02:00
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
*sz = len;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
const WCHAR *msi_get_target_folder( MSIPACKAGE *package, const WCHAR *name )
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
MSIFOLDER *folder = msi_get_loaded_folder( package, name );
|
2011-05-02 16:03:55 +02:00
|
|
|
if (folder) return folder->ResolvedTarget;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetTargetPath (internal)
|
|
|
|
*/
|
2008-11-26 17:15:59 +01:00
|
|
|
static UINT MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
|
|
|
|
awstring *szPathBuf, LPDWORD pcchPathBuf )
|
2005-09-13 13:25:20 +02:00
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
2011-05-02 16:03:55 +02:00
|
|
|
const WCHAR *path;
|
2007-07-04 04:15:36 +02:00
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
2005-09-13 13:25:20 +02:00
|
|
|
|
|
|
|
if (!szFolder)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
|
|
|
if (!package)
|
2007-07-04 04:15:36 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
LPWSTR value = NULL;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR folder;
|
2007-07-04 04:15:36 +02:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
folder = SysAllocString( szFolder );
|
|
|
|
if (!folder)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2007-07-04 04:15:36 +02:00
|
|
|
len = 0;
|
2011-05-02 16:02:55 +02:00
|
|
|
hr = IWineMsiRemotePackage_GetTargetPath( remote_package, folder, NULL, &len );
|
2007-07-04 04:15:36 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
len++;
|
|
|
|
value = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:02:55 +02:00
|
|
|
hr = IWineMsiRemotePackage_GetTargetPath( remote_package, folder, value, &len );
|
2007-07-04 04:15:36 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = msi_strcpy_to_awstring( value, szPathBuf, pcchPathBuf );
|
|
|
|
|
|
|
|
done:
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString( folder );
|
2007-07-04 04:15:36 +02:00
|
|
|
msi_free( value );
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2005-09-13 13:25:20 +02:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
path = msi_get_target_folder( package, szFolder );
|
2005-09-13 13:25:20 +02:00
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
|
|
|
|
if (!path)
|
|
|
|
return ERROR_DIRECTORY;
|
|
|
|
|
|
|
|
r = msi_strcpy_to_awstring( path, szPathBuf, pcchPathBuf );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetTargetPathA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPSTR szPathBuf, LPDWORD pcchPathBuf )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
|
|
|
LPWSTR szwFolder;
|
2005-09-13 13:25:20 +02:00
|
|
|
awstring path;
|
|
|
|
UINT r;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
TRACE("%s %p %p\n", debugstr_a(szFolder), szPathBuf, pcchPathBuf);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
szwFolder = strdupAtoW(szFolder);
|
2005-09-13 13:25:20 +02:00
|
|
|
if (szFolder && !szwFolder)
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
path.unicode = FALSE;
|
|
|
|
path.str.a = szPathBuf;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
r = MSI_GetTargetPath( hInstall, szwFolder, &path, pcchPathBuf );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwFolder );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
return r;
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-09-13 13:25:20 +02:00
|
|
|
* MsiGetTargetPathW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetTargetPathW( MSIHANDLE hInstall, LPCWSTR szFolder,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPWSTR szPathBuf, LPDWORD pcchPathBuf )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
2005-09-13 13:25:20 +02:00
|
|
|
awstring path;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
path.unicode = TRUE;
|
|
|
|
path.str.w = szPathBuf;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
return MSI_GetTargetPath( hInstall, szFolder, &path, pcchPathBuf );
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
static WCHAR *get_source_root( MSIDATABASE *db )
|
|
|
|
{
|
|
|
|
WCHAR *path, *p;
|
|
|
|
|
|
|
|
if ((path = msi_dup_property( db, szSourceDir ))) return path;
|
|
|
|
if ((path = msi_dup_property( db, szDatabase )))
|
|
|
|
{
|
|
|
|
if ((p = strrchrW( path, '\\' ))) p[1] = 0;
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR *msi_resolve_source_folder( MSIPACKAGE *package, const WCHAR *name, MSIFOLDER **folder )
|
|
|
|
{
|
|
|
|
MSIFOLDER *f;
|
|
|
|
LPWSTR p, path = NULL, parent;
|
|
|
|
|
|
|
|
TRACE("working to resolve %s\n", debugstr_w(name));
|
|
|
|
|
|
|
|
if (!strcmpW( name, szSourceDir )) name = szTargetDir;
|
|
|
|
if (!(f = msi_get_loaded_folder( package, name ))) return NULL;
|
|
|
|
|
|
|
|
/* special resolving for root dir */
|
|
|
|
if (!strcmpW( name, szTargetDir ) && !f->ResolvedSource)
|
|
|
|
{
|
|
|
|
f->ResolvedSource = get_source_root( package->db );
|
|
|
|
}
|
|
|
|
if (folder) *folder = f;
|
|
|
|
if (f->ResolvedSource)
|
|
|
|
{
|
|
|
|
path = strdupW( f->ResolvedSource );
|
|
|
|
TRACE(" already resolved to %s\n", debugstr_w(path));
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
if (!f->Parent) return path;
|
|
|
|
parent = f->Parent;
|
|
|
|
TRACE(" ! parent is %s\n", debugstr_w(parent));
|
|
|
|
|
|
|
|
p = msi_resolve_source_folder( package, parent, NULL );
|
|
|
|
|
|
|
|
if (package->WordCount & msidbSumInfoSourceTypeCompressed)
|
|
|
|
path = get_source_root( package->db );
|
|
|
|
else if (package->WordCount & msidbSumInfoSourceTypeSFN)
|
|
|
|
path = msi_build_directory_name( 3, p, f->SourceShortPath, NULL );
|
|
|
|
else
|
|
|
|
path = msi_build_directory_name( 3, p, f->SourceLongPath, NULL );
|
|
|
|
|
|
|
|
TRACE("-> %s\n", debugstr_w(path));
|
|
|
|
f->ResolvedSource = strdupW( path );
|
|
|
|
msi_free( p );
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
/***********************************************************************
|
2011-02-07 09:40:13 +01:00
|
|
|
* MSI_GetSourcePath (internal)
|
2005-09-06 13:05:35 +02:00
|
|
|
*/
|
|
|
|
static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
|
2007-08-09 10:41:41 +02:00
|
|
|
awstring *szPathBuf, LPDWORD pcchPathBuf )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
2005-09-06 13:05:35 +02:00
|
|
|
MSIPACKAGE *package;
|
2005-09-13 13:25:20 +02:00
|
|
|
LPWSTR path;
|
2007-07-04 04:16:15 +02:00
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-06 13:05:35 +02:00
|
|
|
TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
if (!szFolder)
|
2005-09-06 13:05:35 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2007-07-04 04:16:15 +02:00
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
2005-09-06 13:05:35 +02:00
|
|
|
if (!package)
|
2007-07-04 04:16:15 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
LPWSTR value = NULL;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR folder;
|
2007-07-04 04:16:15 +02:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
folder = SysAllocString( szFolder );
|
|
|
|
if (!folder)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2007-07-04 04:16:15 +02:00
|
|
|
len = 0;
|
2011-05-02 16:02:55 +02:00
|
|
|
hr = IWineMsiRemotePackage_GetSourcePath( remote_package, folder, NULL, &len );
|
2007-07-04 04:16:15 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
len++;
|
|
|
|
value = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:02:55 +02:00
|
|
|
hr = IWineMsiRemotePackage_GetSourcePath( remote_package, folder, value, &len );
|
2007-07-04 04:16:15 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = msi_strcpy_to_awstring( value, szPathBuf, pcchPathBuf );
|
|
|
|
|
|
|
|
done:
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString( folder );
|
2007-07-04 04:16:15 +02:00
|
|
|
msi_free( value );
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-06 13:05:35 +02:00
|
|
|
if (szPathBuf->str.w && !pcchPathBuf )
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
path = msi_resolve_source_folder( package, szFolder, NULL );
|
2005-09-06 13:05:35 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-02-07 09:40:13 +01:00
|
|
|
TRACE("path = %s\n", debugstr_w(path));
|
2005-09-06 13:05:35 +02:00
|
|
|
if (!path)
|
|
|
|
return ERROR_DIRECTORY;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-13 13:25:20 +02:00
|
|
|
r = msi_strcpy_to_awstring( path, szPathBuf, pcchPathBuf );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( path );
|
2005-09-06 13:05:35 +02:00
|
|
|
return r;
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-09-06 13:05:35 +02:00
|
|
|
* MsiGetSourcePathA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetSourcePathA( MSIHANDLE hInstall, LPCSTR szFolder,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPSTR szPathBuf, LPDWORD pcchPathBuf )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
2005-09-06 13:05:35 +02:00
|
|
|
LPWSTR folder;
|
|
|
|
awstring str;
|
|
|
|
UINT r;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-06 13:05:35 +02:00
|
|
|
TRACE("%s %p %p\n", szFolder, debugstr_a(szPathBuf), pcchPathBuf);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-06 13:05:35 +02:00
|
|
|
str.unicode = FALSE;
|
|
|
|
str.str.a = szPathBuf;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-09-06 13:05:35 +02:00
|
|
|
folder = strdupAtoW( szFolder );
|
|
|
|
r = MSI_GetSourcePath( hInstall, folder, &str, pcchPathBuf );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( folder );
|
2005-09-06 13:05:35 +02:00
|
|
|
|
|
|
|
return r;
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
|
2005-09-06 13:05:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetSourcePathW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPWSTR szPathBuf, LPDWORD pcchPathBuf )
|
2005-09-06 13:05:35 +02:00
|
|
|
{
|
|
|
|
awstring str;
|
|
|
|
|
|
|
|
TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
|
|
|
|
|
|
|
|
str.unicode = TRUE;
|
|
|
|
str.str.w = szPathBuf;
|
|
|
|
|
|
|
|
return MSI_GetSourcePath( hInstall, szFolder, &str, pcchPathBuf );
|
|
|
|
}
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetTargetPathA (MSI.@)
|
|
|
|
*/
|
2005-11-02 12:43:05 +01:00
|
|
|
UINT WINAPI MsiSetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder,
|
|
|
|
LPCSTR szFolderPath )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
2005-11-02 12:43:05 +01:00
|
|
|
LPWSTR szwFolder = NULL, szwFolderPath = NULL;
|
|
|
|
UINT rc = ERROR_OUTOFMEMORY;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-11-02 12:43:05 +01:00
|
|
|
if ( !szFolder || !szFolderPath )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
szwFolder = strdupAtoW(szFolder);
|
|
|
|
szwFolderPath = strdupAtoW(szFolderPath);
|
2005-11-02 12:43:05 +01:00
|
|
|
if (!szwFolder || !szwFolderPath)
|
|
|
|
goto end;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-11-02 12:43:05 +01:00
|
|
|
rc = MsiSetTargetPathW( hInstall, szwFolder, szwFolderPath );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-11-02 12:43:05 +01:00
|
|
|
end:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(szwFolder);
|
|
|
|
msi_free(szwFolderPath);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
static void set_target_path( MSIPACKAGE *package, MSIFOLDER *folder, const WCHAR *path )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
2011-05-02 16:03:55 +02:00
|
|
|
FolderList *fl;
|
|
|
|
MSIFOLDER *child;
|
2011-05-17 11:10:02 +02:00
|
|
|
WCHAR *target_path;
|
2011-05-02 16:03:55 +02:00
|
|
|
|
2011-05-17 11:10:02 +02:00
|
|
|
if (!(target_path = strdupW( path ))) return;
|
|
|
|
msi_clean_path( target_path );
|
|
|
|
if (strcmpW( target_path, folder->ResolvedTarget ))
|
2011-05-02 16:03:55 +02:00
|
|
|
{
|
2011-05-17 11:10:02 +02:00
|
|
|
msi_free( folder->ResolvedTarget );
|
|
|
|
folder->ResolvedTarget = target_path;
|
|
|
|
msi_set_property( package->db, folder->Directory, folder->ResolvedTarget );
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( fl, &folder->children, FolderList, entry )
|
|
|
|
{
|
|
|
|
child = fl->folder;
|
|
|
|
msi_resolve_target_folder( package, child->Directory, FALSE );
|
|
|
|
}
|
2011-05-02 16:03:55 +02:00
|
|
|
}
|
2011-05-17 11:10:02 +02:00
|
|
|
else msi_free( target_path );
|
2011-05-02 16:03:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_SetTargetPathW( MSIPACKAGE *package, LPCWSTR szFolder, LPCWSTR szFolderPath )
|
|
|
|
{
|
|
|
|
DWORD attrib, len;
|
2005-06-16 22:40:34 +02:00
|
|
|
MSIFOLDER *folder;
|
2006-07-13 00:43:30 +02:00
|
|
|
MSIFILE *file;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
TRACE("%p %s %s\n", package, debugstr_w(szFolder), debugstr_w(szFolderPath));
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-06-17 23:25:51 +02:00
|
|
|
attrib = GetFileAttributesW(szFolderPath);
|
2006-07-15 06:56:09 +02:00
|
|
|
/* native MSI tests writeability by making temporary files at each drive */
|
2011-05-02 16:03:55 +02:00
|
|
|
if (attrib != INVALID_FILE_ATTRIBUTES &&
|
|
|
|
(attrib & FILE_ATTRIBUTE_OFFLINE || attrib & FILE_ATTRIBUTE_READONLY))
|
|
|
|
{
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2011-05-02 16:03:55 +02:00
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
if (!(folder = msi_get_loaded_folder( package, szFolder ))) return ERROR_DIRECTORY;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
len = strlenW( szFolderPath );
|
|
|
|
if (len && szFolderPath[len - 1] != '\\')
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
2011-05-02 16:03:55 +02:00
|
|
|
WCHAR *path = msi_alloc( (len + 2) * sizeof(WCHAR) );
|
|
|
|
memcpy( path, szFolderPath, len * sizeof(WCHAR) );
|
|
|
|
path[len] = '\\';
|
|
|
|
path[len + 1] = 0;
|
|
|
|
set_target_path( package, folder, path );
|
|
|
|
msi_free( path );
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
2011-05-02 16:03:55 +02:00
|
|
|
else set_target_path( package, folder, szFolderPath );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
|
|
|
{
|
|
|
|
const WCHAR *dir;
|
|
|
|
MSICOMPONENT *comp = file->Component;
|
2006-07-13 00:43:30 +02:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
if (!comp->Enabled || (comp->assembly && !comp->assembly->application)) continue;
|
2006-07-13 00:43:30 +02:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
dir = msi_get_target_folder( package, comp->Directory );
|
|
|
|
msi_free( file->TargetPath );
|
2011-05-06 14:39:17 +02:00
|
|
|
file->TargetPath = msi_build_directory_name( 2, dir, file->FileName );
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetTargetPathW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder,
|
|
|
|
LPCWSTR szFolderPath)
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
UINT ret;
|
|
|
|
|
2006-07-15 06:56:09 +02:00
|
|
|
TRACE("%s %s\n",debugstr_w(szFolder),debugstr_w(szFolderPath));
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-11-02 12:43:05 +01:00
|
|
|
if ( !szFolder || !szFolderPath )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
2005-11-02 12:43:05 +01:00
|
|
|
if (!package)
|
2007-07-04 04:16:54 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR folder, path;
|
2007-07-04 04:16:54 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
folder = SysAllocString( szFolder );
|
|
|
|
path = SysAllocString( szFolderPath );
|
|
|
|
if (!folder || !path)
|
|
|
|
{
|
|
|
|
SysFreeString(folder);
|
|
|
|
SysFreeString(path);
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
2007-07-04 04:16:54 +02:00
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
hr = IWineMsiRemotePackage_SetTargetPath( remote_package, folder, path );
|
|
|
|
|
|
|
|
SysFreeString(folder);
|
|
|
|
SysFreeString(path);
|
2007-07-04 04:16:54 +02:00
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-11-02 12:43:05 +01:00
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
ret = MSI_SetTargetPathW( package, szFolder, szFolderPath );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetMode (MSI.@)
|
|
|
|
*
|
|
|
|
* Returns an internal installer state (if it is running in a mode iRunMode)
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hInstall [I] Handle to the installation
|
|
|
|
* hRunMode [I] Checking run mode
|
|
|
|
* MSIRUNMODE_ADMIN Administrative mode
|
|
|
|
* MSIRUNMODE_ADVERTISE Advertisement mode
|
|
|
|
* MSIRUNMODE_MAINTENANCE Maintenance mode
|
|
|
|
* MSIRUNMODE_ROLLBACKENABLED Rollback is enabled
|
|
|
|
* MSIRUNMODE_LOGENABLED Log file is writing
|
|
|
|
* MSIRUNMODE_OPERATIONS Operations in progress??
|
|
|
|
* MSIRUNMODE_REBOOTATEND We need to reboot after installation completed
|
|
|
|
* MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation
|
|
|
|
* MSIRUNMODE_CABINET Files from cabinet are installed
|
|
|
|
* MSIRUNMODE_SOURCESHORTNAMES Long names in source files is suppressed
|
|
|
|
* MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is suppressed
|
|
|
|
* MSIRUNMODE_RESERVED11 Reserved
|
|
|
|
* MSIRUNMODE_WINDOWS9X Running under Windows95/98
|
|
|
|
* MSIRUNMODE_ZAWENABLED Demand installation is supported
|
|
|
|
* MSIRUNMODE_RESERVED14 Reserved
|
|
|
|
* MSIRUNMODE_RESERVED15 Reserved
|
|
|
|
* MSIRUNMODE_SCHEDULED called from install script
|
|
|
|
* MSIRUNMODE_ROLLBACK called from rollback script
|
|
|
|
* MSIRUNMODE_COMMIT called from commit script
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* In the state: TRUE
|
|
|
|
* Not in the state: FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode)
|
|
|
|
{
|
2007-06-25 21:47:38 +02:00
|
|
|
MSIPACKAGE *package;
|
2006-01-03 12:12:15 +01:00
|
|
|
BOOL r = FALSE;
|
|
|
|
|
2010-02-18 12:47:21 +01:00
|
|
|
TRACE("%d %d\n", hInstall, iRunMode);
|
|
|
|
|
2007-06-25 21:47:38 +02:00
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
2007-07-04 04:17:26 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
HRESULT hr;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_GetMode(remote_package, iRunMode, &ret);
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
return ret;
|
|
|
|
|
2007-06-25 21:47:38 +02:00
|
|
|
return FALSE;
|
2007-07-04 04:17:26 +02:00
|
|
|
}
|
2007-06-25 21:47:38 +02:00
|
|
|
|
2006-01-03 12:12:15 +01:00
|
|
|
switch (iRunMode)
|
|
|
|
{
|
2011-05-12 17:22:56 +02:00
|
|
|
case MSIRUNMODE_ADMIN:
|
|
|
|
FIXME("no support for administrative installs\n");
|
2011-05-24 10:50:12 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MSIRUNMODE_ADVERTISE:
|
|
|
|
FIXME("no support for advertised installs\n");
|
2011-05-12 17:22:56 +02:00
|
|
|
break;
|
|
|
|
|
2006-01-03 12:12:15 +01:00
|
|
|
case MSIRUNMODE_WINDOWS9X:
|
|
|
|
if (GetVersion() & 0x80000000)
|
|
|
|
r = TRUE;
|
|
|
|
break;
|
|
|
|
|
2007-07-19 00:55:12 +02:00
|
|
|
case MSIRUNMODE_OPERATIONS:
|
2006-01-03 12:12:15 +01:00
|
|
|
case MSIRUNMODE_RESERVED11:
|
|
|
|
case MSIRUNMODE_RESERVED14:
|
|
|
|
case MSIRUNMODE_RESERVED15:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MSIRUNMODE_SCHEDULED:
|
2007-06-25 21:47:38 +02:00
|
|
|
r = package->scheduled_action_running;
|
|
|
|
break;
|
|
|
|
|
2006-01-03 12:12:15 +01:00
|
|
|
case MSIRUNMODE_ROLLBACK:
|
2007-06-25 21:47:38 +02:00
|
|
|
r = package->rollback_action_running;
|
|
|
|
break;
|
|
|
|
|
2006-01-03 12:12:15 +01:00
|
|
|
case MSIRUNMODE_COMMIT:
|
2007-06-25 21:47:38 +02:00
|
|
|
r = package->commit_action_running;
|
2006-01-03 12:12:15 +01:00
|
|
|
break;
|
|
|
|
|
2010-02-18 12:47:21 +01:00
|
|
|
case MSIRUNMODE_MAINTENANCE:
|
2010-04-21 11:37:54 +02:00
|
|
|
r = msi_get_property_int( package->db, szInstalled, 0 ) != 0;
|
2010-02-18 12:47:21 +01:00
|
|
|
break;
|
|
|
|
|
2011-05-20 12:33:30 +02:00
|
|
|
case MSIRUNMODE_ROLLBACKENABLED:
|
|
|
|
r = msi_get_property_int( package->db, szRollbackDisabled, 0 ) == 0;
|
|
|
|
break;
|
|
|
|
|
2010-02-18 12:47:21 +01:00
|
|
|
case MSIRUNMODE_REBOOTATEND:
|
|
|
|
r = package->need_reboot;
|
|
|
|
break;
|
|
|
|
|
2010-12-15 09:05:07 +01:00
|
|
|
case MSIRUNMODE_LOGENABLED:
|
|
|
|
r = (package->log_file != INVALID_HANDLE_VALUE);
|
|
|
|
break;
|
|
|
|
|
2006-01-03 12:12:15 +01:00
|
|
|
default:
|
2010-02-19 12:23:56 +01:00
|
|
|
FIXME("unimplemented run mode: %d\n", iRunMode);
|
2006-01-03 12:12:15 +01:00
|
|
|
r = TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-20 12:01:35 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2006-01-03 12:12:15 +01:00
|
|
|
return r;
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
|
2005-10-30 20:05:13 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetMode (MSI.@)
|
|
|
|
*/
|
2009-12-04 06:11:49 +01:00
|
|
|
UINT WINAPI MsiSetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode, BOOL fState)
|
2005-10-30 20:05:13 +01:00
|
|
|
{
|
2010-02-18 12:46:58 +01:00
|
|
|
MSIPACKAGE *package;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("%d %d %d\n", hInstall, iRunMode, fState);
|
|
|
|
|
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
|
|
|
if (!package)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_SetMode( remote_package, iRunMode, fState );
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (iRunMode)
|
|
|
|
{
|
|
|
|
case MSIRUNMODE_REBOOTATEND:
|
|
|
|
package->need_reboot = 1;
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MSIRUNMODE_REBOOTNOW:
|
2010-02-19 12:23:56 +01:00
|
|
|
FIXME("unimplemented run mode: %d\n", iRunMode);
|
2010-02-18 12:46:58 +01:00
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
r = ERROR_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
2010-05-20 12:01:35 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2010-02-18 12:46:58 +01:00
|
|
|
return r;
|
2005-10-30 20:05:13 +01:00
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetFeatureStateA (MSI.@)
|
|
|
|
*
|
|
|
|
* According to the docs, when this is called it immediately recalculates
|
|
|
|
* all the component states as well
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature,
|
|
|
|
INSTALLSTATE iState)
|
|
|
|
{
|
|
|
|
LPWSTR szwFeature = NULL;
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
szwFeature = strdupAtoW(szFeature);
|
|
|
|
|
|
|
|
if (!szwFeature)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
rc = MsiSetFeatureStateW(hInstall,szwFeature, iState);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(szwFeature);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
/* update component state based on a feature change */
|
|
|
|
void ACTION_UpdateComponentStates( MSIPACKAGE *package, MSIFEATURE *feature )
|
|
|
|
{
|
|
|
|
INSTALLSTATE newstate;
|
|
|
|
ComponentList *cl;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
newstate = feature->ActionRequest;
|
|
|
|
if (newstate == INSTALLSTATE_ABSENT) newstate = INSTALLSTATE_UNKNOWN;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(cl, &feature->Components, ComponentList, entry)
|
|
|
|
{
|
|
|
|
MSICOMPONENT *component = cl->component;
|
|
|
|
|
|
|
|
if (!component->Enabled) continue;
|
|
|
|
|
|
|
|
TRACE("Modifying (%d): Component %s (Installed %d, Action %d, Request %d)\n",
|
|
|
|
newstate, debugstr_w(component->Component), component->Installed,
|
|
|
|
component->Action, component->ActionRequest);
|
|
|
|
|
|
|
|
if (newstate == INSTALLSTATE_LOCAL)
|
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_LOCAL;
|
|
|
|
component->ActionRequest = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ComponentList *clist;
|
|
|
|
MSIFEATURE *f;
|
|
|
|
|
|
|
|
component->hasLocalFeature = FALSE;
|
|
|
|
|
|
|
|
component->Action = newstate;
|
|
|
|
component->ActionRequest = newstate;
|
|
|
|
/* if any other feature wants it local we need to set it local */
|
|
|
|
LIST_FOR_EACH_ENTRY(f, &package->features, MSIFEATURE, entry)
|
|
|
|
{
|
|
|
|
if ( f->ActionRequest != INSTALLSTATE_LOCAL &&
|
|
|
|
f->ActionRequest != INSTALLSTATE_SOURCE )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_ENTRY(clist, &f->Components, ComponentList, entry)
|
|
|
|
{
|
|
|
|
if (clist->component == component &&
|
|
|
|
(f->ActionRequest == INSTALLSTATE_LOCAL ||
|
|
|
|
f->ActionRequest == INSTALLSTATE_SOURCE))
|
|
|
|
{
|
|
|
|
TRACE("Saved by %s\n", debugstr_w(f->Feature));
|
|
|
|
component->hasLocalFeature = TRUE;
|
|
|
|
|
|
|
|
if (component->Attributes & msidbComponentAttributesOptional)
|
|
|
|
{
|
|
|
|
if (f->Attributes & msidbFeatureAttributesFavorSource)
|
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_SOURCE;
|
|
|
|
component->ActionRequest = INSTALLSTATE_SOURCE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_LOCAL;
|
|
|
|
component->ActionRequest = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (component->Attributes & msidbComponentAttributesSourceOnly)
|
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_SOURCE;
|
|
|
|
component->ActionRequest = INSTALLSTATE_SOURCE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_LOCAL;
|
|
|
|
component->ActionRequest = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("Result (%d): Component %s (Installed %d, Action %d, Request %d)\n",
|
|
|
|
newstate, debugstr_w(component->Component), component->Installed,
|
|
|
|
component->Action, component->ActionRequest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MSI_SetFeatureStateW( MSIPACKAGE *package, LPCWSTR szFeature, INSTALLSTATE iState )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature, *child;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2006-07-15 06:56:09 +02:00
|
|
|
TRACE("%s %i\n", debugstr_w(szFeature), iState);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
feature = msi_get_loaded_feature( package, szFeature );
|
2005-08-22 16:09:17 +02:00
|
|
|
if (!feature)
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_UNKNOWN_FEATURE;
|
|
|
|
|
|
|
|
if (iState == INSTALLSTATE_ADVERTISED &&
|
2005-08-22 16:09:17 +02:00
|
|
|
feature->Attributes & msidbFeatureAttributesDisallowAdvertise)
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2010-11-11 10:44:37 +01:00
|
|
|
feature->ActionRequest = iState;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2010-12-24 15:32:01 +01:00
|
|
|
ACTION_UpdateComponentStates( package, feature );
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
/* update all the features that are children of this feature */
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( child, &package->features, MSIFEATURE, entry )
|
2005-06-16 22:40:34 +02:00
|
|
|
{
|
2010-10-19 11:27:44 +02:00
|
|
|
if (child->Feature_Parent && !strcmpW( szFeature, child->Feature_Parent ))
|
2005-08-22 16:09:17 +02:00
|
|
|
MSI_SetFeatureStateW(package, child->Feature, iState);
|
2005-06-16 22:40:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetFeatureStateW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
|
|
|
|
INSTALLSTATE iState)
|
|
|
|
{
|
|
|
|
MSIPACKAGE* package;
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
|
2006-07-15 06:56:09 +02:00
|
|
|
TRACE("%s %i\n",debugstr_w(szFeature), iState);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
2007-07-04 04:18:04 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR feature;
|
2007-07-04 04:18:04 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
feature = SysAllocString(szFeature);
|
|
|
|
if (!feature)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_SetFeatureState(remote_package, feature, iState);
|
2007-07-04 04:18:04 +02:00
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString(feature);
|
2007-07-04 04:18:04 +02:00
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
rc = MSI_SetFeatureStateW(package,szFeature,iState);
|
|
|
|
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-06-10 10:13:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetFeatureAttributesA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetFeatureAttributesA( MSIHANDLE handle, LPCSTR feature, DWORD attrs )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
WCHAR *featureW = NULL;
|
|
|
|
|
|
|
|
TRACE("%u, %s, 0x%08x\n", handle, debugstr_a(feature), attrs);
|
|
|
|
|
|
|
|
if (feature && !(featureW = strdupAtoW( feature ))) return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = MsiSetFeatureAttributesW( handle, featureW, attrs );
|
|
|
|
msi_free( featureW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD unmap_feature_attributes( DWORD attrs )
|
|
|
|
{
|
|
|
|
DWORD ret = 0;
|
|
|
|
|
|
|
|
if (attrs & INSTALLFEATUREATTRIBUTE_FAVORLOCAL) ret = msidbFeatureAttributesFavorLocal;
|
|
|
|
if (attrs & INSTALLFEATUREATTRIBUTE_FAVORSOURCE) ret |= msidbFeatureAttributesFavorSource;
|
|
|
|
if (attrs & INSTALLFEATUREATTRIBUTE_FOLLOWPARENT) ret |= msidbFeatureAttributesFollowParent;
|
|
|
|
if (attrs & INSTALLFEATUREATTRIBUTE_FAVORADVERTISE) ret |= msidbFeatureAttributesFavorAdvertise;
|
|
|
|
if (attrs & INSTALLFEATUREATTRIBUTE_DISALLOWADVERTISE) ret |= msidbFeatureAttributesDisallowAdvertise;
|
|
|
|
if (attrs & INSTALLFEATUREATTRIBUTE_NOUNSUPPORTEDADVERTISE) ret |= msidbFeatureAttributesNoUnsupportedAdvertise;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetFeatureAttributesW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetFeatureAttributesW( MSIHANDLE handle, LPCWSTR name, DWORD attrs )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
WCHAR *costing;
|
|
|
|
|
|
|
|
TRACE("%u, %s, 0x%08x\n", handle, debugstr_w(name), attrs);
|
|
|
|
|
|
|
|
if (!name || !name[0]) return ERROR_UNKNOWN_FEATURE;
|
|
|
|
|
|
|
|
if (!(package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE )))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
costing = msi_dup_property( package->db, szCostingComplete );
|
|
|
|
if (!costing || !strcmpW( costing, szOne ))
|
|
|
|
{
|
|
|
|
msi_free( costing );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
msi_free( costing );
|
|
|
|
if (!(feature = msi_get_loaded_feature( package, name )))
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_UNKNOWN_FEATURE;
|
|
|
|
}
|
|
|
|
feature->Attributes = unmap_feature_attributes( attrs );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureStateA (MSI.@)
|
|
|
|
*/
|
2006-08-04 23:27:42 +02:00
|
|
|
UINT WINAPI MsiGetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature,
|
2005-06-16 22:40:34 +02:00
|
|
|
INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
|
|
|
|
{
|
|
|
|
LPWSTR szwFeature = NULL;
|
|
|
|
UINT rc;
|
|
|
|
|
2011-06-10 10:13:47 +02:00
|
|
|
if (szFeature && !(szwFeature = strdupAtoW(szFeature))) return ERROR_OUTOFMEMORY;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-06-10 10:13:47 +02:00
|
|
|
rc = MsiGetFeatureStateW(hInstall, szwFeature, piInstalled, piAction);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwFeature);
|
2005-06-16 22:40:34 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-08-04 23:27:42 +02:00
|
|
|
UINT MSI_GetFeatureStateW(MSIPACKAGE *package, LPCWSTR szFeature,
|
2005-06-16 22:40:34 +02:00
|
|
|
INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
|
|
|
|
{
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
feature = msi_get_loaded_feature(package,szFeature);
|
2005-08-22 16:09:17 +02:00
|
|
|
if (!feature)
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_UNKNOWN_FEATURE;
|
|
|
|
|
|
|
|
if (piInstalled)
|
2005-08-22 16:09:17 +02:00
|
|
|
*piInstalled = feature->Installed;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
if (piAction)
|
2010-11-11 10:44:37 +01:00
|
|
|
*piAction = feature->ActionRequest;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2010-11-11 10:44:37 +01:00
|
|
|
TRACE("returning %i %i\n", feature->Installed, feature->ActionRequest);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureStateW (MSI.@)
|
|
|
|
*/
|
2006-08-04 23:27:42 +02:00
|
|
|
UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
|
2005-06-16 22:40:34 +02:00
|
|
|
INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
|
|
|
|
{
|
|
|
|
MSIPACKAGE* package;
|
|
|
|
UINT ret;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled, piAction);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
2007-07-04 04:18:44 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR feature;
|
2007-07-04 04:18:44 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
feature = SysAllocString(szFeature);
|
|
|
|
if (!feature)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_GetFeatureState(remote_package, feature,
|
2007-07-04 04:18:44 +02:00
|
|
|
piInstalled, piAction);
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString(feature);
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
|
2007-07-04 04:18:44 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
ret = MSI_GetFeatureStateW(package, szFeature, piInstalled, piAction);
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-15 23:56:19 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureCostA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureCostA(MSIHANDLE hInstall, LPCSTR szFeature,
|
2007-08-09 10:41:41 +02:00
|
|
|
MSICOSTTREE iCostTree, INSTALLSTATE iState, LPINT piCost)
|
2006-08-15 23:56:19 +02:00
|
|
|
{
|
2009-11-08 13:34:43 +01:00
|
|
|
LPWSTR szwFeature = NULL;
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
szwFeature = strdupAtoW(szFeature);
|
|
|
|
|
|
|
|
rc = MsiGetFeatureCostW(hInstall, szwFeature, iCostTree, iState, piCost);
|
|
|
|
|
|
|
|
msi_free(szwFeature);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-06-11 15:20:46 +02:00
|
|
|
static INT feature_cost( MSIFEATURE *feature )
|
2009-11-08 13:34:43 +01:00
|
|
|
{
|
2010-06-11 15:20:46 +02:00
|
|
|
INT cost = 0;
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( comp, &feature->Components, MSICOMPONENT, entry )
|
|
|
|
{
|
|
|
|
cost += comp->Cost;
|
|
|
|
}
|
|
|
|
return cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_GetFeatureCost( MSIPACKAGE *package, MSIFEATURE *feature, MSICOSTTREE tree,
|
|
|
|
INSTALLSTATE state, LPINT cost )
|
|
|
|
{
|
|
|
|
TRACE("%s, %u, %d, %p\n", debugstr_w(feature->Feature), tree, state, cost);
|
|
|
|
|
|
|
|
*cost = 0;
|
|
|
|
switch (tree)
|
|
|
|
{
|
|
|
|
case MSICOSTTREE_CHILDREN:
|
|
|
|
{
|
|
|
|
MSIFEATURE *child;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( child, &feature->Children, MSIFEATURE, entry )
|
|
|
|
{
|
|
|
|
if (child->ActionRequest == state)
|
|
|
|
*cost += feature_cost( child );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MSICOSTTREE_PARENTS:
|
|
|
|
{
|
|
|
|
const WCHAR *feature_parent = feature->Feature_Parent;
|
|
|
|
for (;;)
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
MSIFEATURE *parent = msi_get_loaded_feature( package, feature_parent );
|
2010-06-11 15:20:46 +02:00
|
|
|
if (!parent)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (parent->ActionRequest == state)
|
|
|
|
*cost += feature_cost( parent );
|
|
|
|
|
|
|
|
feature_parent = parent->Feature_Parent;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MSICOSTTREE_SELFONLY:
|
|
|
|
if (feature->ActionRequest == state)
|
|
|
|
*cost = feature_cost( feature );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("unhandled cost tree %u\n", tree);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cost /= 512;
|
2006-08-15 23:56:19 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureCostW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureCostW(MSIHANDLE hInstall, LPCWSTR szFeature,
|
2007-08-09 10:41:41 +02:00
|
|
|
MSICOSTTREE iCostTree, INSTALLSTATE iState, LPINT piCost)
|
2006-08-15 23:56:19 +02:00
|
|
|
{
|
2009-11-08 13:34:43 +01:00
|
|
|
MSIPACKAGE *package;
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("(%d %s %i %i %p)\n", hInstall, debugstr_w(szFeature),
|
2006-08-15 23:56:19 +02:00
|
|
|
iCostTree, iState, piCost);
|
2009-11-08 13:34:43 +01:00
|
|
|
|
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR feature;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
feature = SysAllocString(szFeature);
|
|
|
|
if (!feature)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_GetFeatureCost(remote_package, feature,
|
|
|
|
iCostTree, iState, piCost);
|
|
|
|
|
|
|
|
SysFreeString(feature);
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
feature = msi_get_loaded_feature(package, szFeature);
|
2009-11-08 13:34:43 +01:00
|
|
|
|
|
|
|
if (feature)
|
|
|
|
ret = MSI_GetFeatureCost(package, feature, iCostTree, iState, piCost);
|
|
|
|
else
|
|
|
|
ret = ERROR_UNKNOWN_FEATURE;
|
|
|
|
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ret;
|
2006-08-15 23:56:19 +02:00
|
|
|
}
|
|
|
|
|
2005-08-24 12:56:27 +02:00
|
|
|
/***********************************************************************
|
2011-06-10 10:13:34 +02:00
|
|
|
* MsiGetFeatureInfoA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureInfoA( MSIHANDLE handle, LPCSTR feature, LPDWORD attrs,
|
|
|
|
LPSTR title, LPDWORD title_len, LPSTR help, LPDWORD help_len )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
WCHAR *titleW = NULL, *helpW = NULL, *featureW = NULL;
|
|
|
|
|
|
|
|
TRACE("%u, %s, %p, %p, %p, %p, %p\n", handle, debugstr_a(feature), attrs, title,
|
|
|
|
title_len, help, help_len);
|
|
|
|
|
|
|
|
if (feature && !(featureW = strdupAtoW( feature ))) return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (title && title_len && !(titleW = msi_alloc( *title_len * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
msi_free( featureW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
if (help && help_len && !(helpW = msi_alloc( *help_len * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
msi_free( featureW );
|
|
|
|
msi_free( titleW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
r = MsiGetFeatureInfoW( handle, featureW, attrs, titleW, title_len, helpW, help_len );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (titleW) WideCharToMultiByte( CP_ACP, 0, titleW, -1, title, *title_len + 1, NULL, NULL );
|
|
|
|
if (helpW) WideCharToMultiByte( CP_ACP, 0, helpW, -1, help, *help_len + 1, NULL, NULL );
|
|
|
|
}
|
|
|
|
msi_free( titleW );
|
|
|
|
msi_free( helpW );
|
|
|
|
msi_free( featureW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD map_feature_attributes( DWORD attrs )
|
|
|
|
{
|
|
|
|
DWORD ret = 0;
|
|
|
|
|
|
|
|
if (attrs == msidbFeatureAttributesFavorLocal) ret |= INSTALLFEATUREATTRIBUTE_FAVORLOCAL;
|
|
|
|
if (attrs & msidbFeatureAttributesFavorSource) ret |= INSTALLFEATUREATTRIBUTE_FAVORSOURCE;
|
|
|
|
if (attrs & msidbFeatureAttributesFollowParent) ret |= INSTALLFEATUREATTRIBUTE_FOLLOWPARENT;
|
|
|
|
if (attrs & msidbFeatureAttributesFavorAdvertise) ret |= INSTALLFEATUREATTRIBUTE_FAVORADVERTISE;
|
|
|
|
if (attrs & msidbFeatureAttributesDisallowAdvertise) ret |= INSTALLFEATUREATTRIBUTE_DISALLOWADVERTISE;
|
|
|
|
if (attrs & msidbFeatureAttributesNoUnsupportedAdvertise) ret |= INSTALLFEATUREATTRIBUTE_NOUNSUPPORTEDADVERTISE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT MSI_GetFeatureInfo( MSIPACKAGE *package, LPCWSTR name, LPDWORD attrs,
|
|
|
|
LPWSTR title, LPDWORD title_len, LPWSTR help, LPDWORD help_len )
|
|
|
|
{
|
|
|
|
UINT r = ERROR_SUCCESS;
|
|
|
|
MSIFEATURE *feature = msi_get_loaded_feature( package, name );
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!feature) return ERROR_UNKNOWN_FEATURE;
|
|
|
|
if (attrs) *attrs = map_feature_attributes( feature->Attributes );
|
|
|
|
if (title_len)
|
|
|
|
{
|
|
|
|
if (feature->Title) len = strlenW( feature->Title );
|
|
|
|
else len = 0;
|
|
|
|
if (*title_len <= len)
|
|
|
|
{
|
|
|
|
*title_len = len;
|
|
|
|
if (title) r = ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
else if (title)
|
|
|
|
{
|
|
|
|
if (feature->Title) strcpyW( title, feature->Title );
|
|
|
|
else *title = 0;
|
|
|
|
*title_len = len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (help_len)
|
|
|
|
{
|
|
|
|
if (feature->Description) len = strlenW( feature->Description );
|
|
|
|
else len = 0;
|
|
|
|
if (*help_len <= len)
|
|
|
|
{
|
|
|
|
*help_len = len;
|
|
|
|
if (help) r = ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
else if (help)
|
|
|
|
{
|
|
|
|
if (feature->Description) strcpyW( help, feature->Description );
|
|
|
|
else *help = 0;
|
|
|
|
*help_len = len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureInfoW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureInfoW( MSIHANDLE handle, LPCWSTR feature, LPDWORD attrs,
|
|
|
|
LPWSTR title, LPDWORD title_len, LPWSTR help, LPDWORD help_len )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
|
|
|
|
TRACE("%u, %s, %p, %p, %p, %p, %p\n", handle, debugstr_w(feature), attrs, title,
|
|
|
|
title_len, help, help_len);
|
|
|
|
|
|
|
|
if (!feature) return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!(package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE )))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
/* features may not have been loaded yet */
|
|
|
|
msi_load_all_components( package );
|
|
|
|
msi_load_all_features( package );
|
|
|
|
|
|
|
|
r = MSI_GetFeatureInfo( package, feature, attrs, title, title_len, help, help_len );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-08-24 12:56:27 +02:00
|
|
|
* MsiSetComponentStateA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetComponentStateA(MSIHANDLE hInstall, LPCSTR szComponent,
|
|
|
|
INSTALLSTATE iState)
|
|
|
|
{
|
2005-08-24 20:13:09 +02:00
|
|
|
UINT rc;
|
|
|
|
LPWSTR szwComponent = strdupAtoW(szComponent);
|
|
|
|
|
|
|
|
rc = MsiSetComponentStateW(hInstall, szwComponent, iState);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(szwComponent);
|
2005-08-24 20:13:09 +02:00
|
|
|
|
|
|
|
return rc;
|
2005-08-24 12:56:27 +02:00
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetComponentStateA (MSI.@)
|
|
|
|
*/
|
2006-08-04 23:27:42 +02:00
|
|
|
UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPCSTR szComponent,
|
2005-06-16 22:40:34 +02:00
|
|
|
INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
|
|
|
|
{
|
|
|
|
LPWSTR szwComponent= NULL;
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
szwComponent= strdupAtoW(szComponent);
|
|
|
|
|
|
|
|
rc = MsiGetComponentStateW(hInstall,szwComponent,piInstalled, piAction);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwComponent);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-08-24 20:13:09 +02:00
|
|
|
static UINT MSI_SetComponentStateW(MSIPACKAGE *package, LPCWSTR szComponent,
|
|
|
|
INSTALLSTATE iState)
|
|
|
|
{
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
|
|
|
TRACE("%p %s %d\n", package, debugstr_w(szComponent), iState);
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, szComponent);
|
2005-08-24 20:13:09 +02:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_UNKNOWN_COMPONENT;
|
|
|
|
|
2010-11-30 15:18:00 +01:00
|
|
|
if (comp->Enabled)
|
2011-02-10 15:56:15 +01:00
|
|
|
comp->Action = iState;
|
2005-08-24 20:13:09 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-08-04 23:27:42 +02:00
|
|
|
UINT MSI_GetComponentStateW(MSIPACKAGE *package, LPCWSTR szComponent,
|
2005-06-16 22:40:34 +02:00
|
|
|
INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
|
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
TRACE("%p %s %p %p\n", package, debugstr_w(szComponent),
|
|
|
|
piInstalled, piAction);
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package,szComponent);
|
2005-08-22 11:15:23 +02:00
|
|
|
if (!comp)
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_UNKNOWN_COMPONENT;
|
|
|
|
|
|
|
|
if (piInstalled)
|
2010-12-23 17:07:13 +01:00
|
|
|
{
|
|
|
|
if (comp->Enabled)
|
|
|
|
*piInstalled = comp->Installed;
|
|
|
|
else
|
|
|
|
*piInstalled = INSTALLSTATE_UNKNOWN;
|
|
|
|
}
|
2005-06-16 22:40:34 +02:00
|
|
|
|
|
|
|
if (piAction)
|
2010-12-23 17:07:13 +01:00
|
|
|
{
|
|
|
|
if (comp->Enabled)
|
|
|
|
*piAction = comp->Action;
|
|
|
|
else
|
|
|
|
*piAction = INSTALLSTATE_UNKNOWN;
|
|
|
|
}
|
2005-06-16 22:40:34 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
TRACE("states (%i, %i)\n", comp->Installed, comp->Action );
|
2005-06-16 22:40:34 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-24 12:56:27 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetComponentStateW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent,
|
|
|
|
INSTALLSTATE iState)
|
|
|
|
{
|
2005-08-24 20:13:09 +02:00
|
|
|
MSIPACKAGE* package;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
2007-07-04 04:19:44 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR component;
|
2007-07-04 04:19:44 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
component = SysAllocString(szComponent);
|
|
|
|
if (!component)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_SetComponentState(remote_package, component, iState);
|
2007-07-04 04:19:44 +02:00
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString(component);
|
2007-07-04 04:19:44 +02:00
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-24 20:13:09 +02:00
|
|
|
ret = MSI_SetComponentStateW(package, szComponent, iState);
|
|
|
|
msiobj_release(&package->hdr);
|
|
|
|
return ret;
|
2005-08-24 12:56:27 +02:00
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetComponentStateW (MSI.@)
|
|
|
|
*/
|
2006-08-04 23:27:42 +02:00
|
|
|
UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent,
|
2005-06-16 22:40:34 +02:00
|
|
|
INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
|
|
|
|
{
|
|
|
|
MSIPACKAGE* package;
|
|
|
|
UINT ret;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s %p %p\n", hInstall, debugstr_w(szComponent),
|
2005-06-16 22:40:34 +02:00
|
|
|
piInstalled, piAction);
|
|
|
|
|
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
2007-07-04 04:19:16 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR component;
|
2007-07-04 04:19:16 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
component = SysAllocString(szComponent);
|
|
|
|
if (!component)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_GetComponentState(remote_package, component,
|
2007-07-04 04:19:16 +02:00
|
|
|
piInstalled, piAction);
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString(component);
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
|
2007-07-04 04:19:16 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:40:34 +02:00
|
|
|
ret = MSI_GetComponentStateW( package, szComponent, piInstalled, piAction);
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
2005-07-10 19:39:14 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetLanguage (MSI.@)
|
|
|
|
*/
|
|
|
|
LANGID WINAPI MsiGetLanguage(MSIHANDLE hInstall)
|
|
|
|
{
|
|
|
|
MSIPACKAGE* package;
|
|
|
|
LANGID langid;
|
2011-05-02 16:04:25 +02:00
|
|
|
|
2005-07-10 19:39:14 +02:00
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
2007-07-04 04:20:17 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
LANGID lang;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_GetLanguage(remote_package, &lang);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
return lang;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2005-07-10 19:39:14 +02:00
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
langid = msi_get_property_int( package->db, szProductLanguage, 0 );
|
2006-07-15 06:56:09 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2005-07-10 19:39:14 +02:00
|
|
|
return langid;
|
|
|
|
}
|
2006-07-18 11:43:33 +02:00
|
|
|
|
2006-07-19 20:17:28 +02:00
|
|
|
UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel )
|
2006-07-18 11:43:33 +02:00
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = { '%','d',0 };
|
|
|
|
WCHAR level[6];
|
|
|
|
UINT r;
|
|
|
|
|
2006-07-19 20:17:28 +02:00
|
|
|
TRACE("%p %i\n", package, iInstallLevel);
|
2006-07-18 11:43:33 +02:00
|
|
|
|
2008-04-05 05:48:20 +02:00
|
|
|
if (iInstallLevel > 32767)
|
2006-07-18 11:43:33 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2008-04-05 05:48:20 +02:00
|
|
|
if (iInstallLevel < 1)
|
|
|
|
return MSI_SetFeatureStates( package );
|
|
|
|
|
2006-07-18 11:43:33 +02:00
|
|
|
sprintfW( level, fmt, iInstallLevel );
|
2010-04-21 11:38:40 +02:00
|
|
|
r = msi_set_property( package->db, szInstallLevel, level );
|
2006-07-19 20:17:16 +02:00
|
|
|
if ( r == ERROR_SUCCESS )
|
|
|
|
r = MSI_SetFeatureStates( package );
|
|
|
|
|
2006-07-19 20:17:28 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetInstallLevel (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiSetInstallLevel(MSIHANDLE hInstall, int iInstallLevel)
|
|
|
|
{
|
|
|
|
MSIPACKAGE* package;
|
|
|
|
UINT r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %i\n", hInstall, iInstallLevel);
|
2006-07-19 20:17:28 +02:00
|
|
|
|
2007-07-04 04:20:48 +02:00
|
|
|
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_SetInstallLevel(remote_package, iInstallLevel);
|
|
|
|
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2006-07-19 20:17:28 +02:00
|
|
|
|
|
|
|
r = MSI_SetInstallLevel( package, iInstallLevel );
|
|
|
|
|
2006-07-18 11:43:33 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2006-07-19 20:17:16 +02:00
|
|
|
|
2006-07-18 11:43:33 +02:00
|
|
|
return r;
|
|
|
|
}
|
2006-11-07 19:47:05 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureValidStatesW (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureValidStatesW(MSIHANDLE hInstall, LPCWSTR szFeature,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pInstallState)
|
2006-11-07 19:47:05 +01:00
|
|
|
{
|
|
|
|
if(pInstallState) *pInstallState = 1<<INSTALLSTATE_LOCAL;
|
2009-01-04 14:14:15 +01:00
|
|
|
FIXME("%d %s %p stub returning %d\n",
|
2006-11-07 19:47:05 +01:00
|
|
|
hInstall, debugstr_w(szFeature), pInstallState, pInstallState ? *pInstallState : 0);
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureValidStatesA (MSI.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureValidStatesA(MSIHANDLE hInstall, LPCSTR szFeature,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pInstallState)
|
2006-11-07 19:47:05 +01:00
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
LPWSTR szwFeature = strdupAtoW(szFeature);
|
|
|
|
|
|
|
|
ret = MsiGetFeatureValidStatesW(hInstall, szwFeature, pInstallState);
|
|
|
|
|
|
|
|
msi_free(szwFeature);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|