Commit 68d61588 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Implement and test MsiEnumComponentCostsA/W.

parent f2231f84
......@@ -2007,10 +2007,7 @@ static UINT load_all_folders( MSIPACKAGE *package )
*/
static UINT ACTION_CostInitialize(MSIPACKAGE *package)
{
static const WCHAR szCosting[] =
{'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
msi_set_property( package->db, szCosting, szZero );
msi_set_property( package->db, szCostingComplete, szZero );
msi_set_property( package->db, cszRootDrive, c_colon );
load_all_folders( package );
......@@ -2639,8 +2636,6 @@ static UINT ACTION_CostFinalize(MSIPACKAGE *package)
static const WCHAR ConditionQuery[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','C','o','n','d','i','t','i','o','n','`',0};
static const WCHAR szCosting[] =
{'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
static const WCHAR szlevel[] =
{'I','N','S','T','A','L','L','L','E','V','E','L',0};
static const WCHAR szOutOfDiskSpace[] =
......@@ -2691,7 +2686,7 @@ static UINT ACTION_CostFinalize(MSIPACKAGE *package)
TRACE("Calculating file cost\n");
calculate_file_cost( package );
msi_set_property( package->db, szCosting, szOne );
msi_set_property( package->db, szCostingComplete, szOne );
/* set default run level if not set */
level = msi_dup_property( package->db, szlevel );
if (!level)
......
......@@ -1794,16 +1794,101 @@ UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
return ERROR_SUCCESS;
}
UINT WINAPI MsiEnumComponentCostsW(MSIHANDLE hInstall, LPCWSTR szComponent,
DWORD dwIndex, INSTALLSTATE iState,
LPWSTR lpDriveBuf, DWORD *pcchDriveBuf,
int *piCost, int *pTempCost)
UINT WINAPI MsiEnumComponentCostsA( MSIHANDLE handle, LPCSTR component, DWORD index,
INSTALLSTATE state, LPSTR drive, DWORD *buflen,
int *cost, int *temp )
{
FIXME("(%d, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall,
debugstr_w(szComponent), dwIndex, iState, lpDriveBuf,
pcchDriveBuf, piCost, pTempCost);
UINT r;
DWORD len;
WCHAR *driveW, *componentW = NULL;
TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle, debugstr_a(component), index,
state, drive, buflen, cost, temp);
if (!drive || !buflen) return ERROR_INVALID_PARAMETER;
if (component && !(componentW = strdupAtoW( component ))) return ERROR_OUTOFMEMORY;
len = *buflen;
if (!(driveW = msi_alloc( len * sizeof(WCHAR) )))
{
msi_free( componentW );
return ERROR_OUTOFMEMORY;
}
r = MsiEnumComponentCostsW( handle, componentW, index, state, driveW, buflen, cost, temp );
if (!r)
{
WideCharToMultiByte( CP_ACP, 0, driveW, -1, drive, len, NULL, NULL );
}
msi_free( componentW );
msi_free( driveW );
return r;
}
UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD index,
INSTALLSTATE state, LPWSTR drive, DWORD *buflen,
int *cost, int *temp )
{
UINT r = ERROR_NO_MORE_ITEMS;
MSICOMPONENT *comp = NULL;
MSIPACKAGE *package;
MSIFILE *file;
STATSTG stat = {0};
WCHAR path[MAX_PATH];
TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle, debugstr_w(component), index,
state, drive, buflen, cost, temp);
if (!drive || !buflen || !cost || !temp) return ERROR_INVALID_PARAMETER;
if (!(package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE ))) return ERROR_INVALID_HANDLE;
if (!msi_get_property_int( package->db, szCostingComplete, 0 ))
{
msiobj_release( &package->hdr );
return ERROR_FUNCTION_NOT_CALLED;
}
if (component && component[0] && !(comp = get_loaded_component( package, component )))
{
msiobj_release( &package->hdr );
return ERROR_UNKNOWN_COMPONENT;
}
if (*buflen < 3)
{
*buflen = 2;
msiobj_release( &package->hdr );
return ERROR_MORE_DATA;
}
if (index)
{
msiobj_release( &package->hdr );
return ERROR_NO_MORE_ITEMS;
}
return ERROR_NO_MORE_ITEMS;
drive[0] = 0;
*cost = *temp = 0;
if (component && component[0])
{
*cost = max( 8, comp->Cost / 512 );
if (comp->assembly && !comp->assembly->application) *temp = comp->Cost;
if ((file = get_loaded_file( package, comp->KeyPath )))
{
drive[0] = file->TargetPath[0];
drive[1] = ':';
drive[2] = 0;
*buflen = 2;
r = ERROR_SUCCESS;
}
}
else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK)
{
*temp = max( 8, stat.cbSize.QuadPart / 512 );
GetWindowsDirectoryW( path, MAX_PATH );
drive[0] = path[0];
drive[1] = ':';
drive[2] = 0;
*buflen = 2;
r = ERROR_SUCCESS;
}
msiobj_release( &package->hdr );
return r;
}
UINT WINAPI MsiQueryComponentStateA(LPCSTR szProductCode,
......
......@@ -213,7 +213,7 @@
217 stdcall MsiGetShortcutTargetW(wstr ptr ptr ptr)
218 stdcall MsiGetFileHashA(str long ptr)
219 stdcall MsiGetFileHashW(wstr long ptr)
220 stub MsiEnumComponentCostsA
220 stdcall MsiEnumComponentCostsA(long str long long ptr ptr ptr ptr)
221 stdcall MsiEnumComponentCostsW(long wstr long long ptr ptr ptr ptr)
222 stdcall MsiCreateAndVerifyInstallerDirectory(long)
223 stdcall MsiGetFileSignatureInformationA(str long ptr ptr ptr)
......
......@@ -1108,6 +1108,7 @@ static const WCHAR szWow6432Node[] = {'W','o','w','6','4','3','2','N','o','d','e
static const WCHAR szStreams[] = {'_','S','t','r','e','a','m','s',0};
static const WCHAR szStorages[] = {'_','S','t','o','r','a','g','e','s',0};
static const WCHAR szMsiPublishAssemblies[] = {'M','s','i','P','u','b','l','i','s','h','A','s','s','e','m','b','l','i','e','s',0};
static const WCHAR szCostingComplete[] = {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0};
/* memory allocation macro functions */
static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment