From 67f15e7149e9c25c8098831e45a29c983d3e15bb Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Fri, 11 Jun 2010 15:20:46 +0200 Subject: [PATCH] msi: Implement MsiGetFeatureCostA/W. --- dlls/msi/install.c | 63 +++++++++++++++++++++++++++++++++++++++++----- dlls/msi/msipriv.h | 1 - 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/dlls/msi/install.c b/dlls/msi/install.c index fda49b90d8d..fa3e4f9e382 100644 --- a/dlls/msi/install.c +++ b/dlls/msi/install.c @@ -993,13 +993,64 @@ UINT WINAPI MsiGetFeatureCostA(MSIHANDLE hInstall, LPCSTR szFeature, return rc; } -UINT MSI_GetFeatureCost(MSIPACKAGE *package, MSIFEATURE *feature, - MSICOSTTREE iCostTree, INSTALLSTATE iState, - LPINT piCost) +static INT feature_cost( MSIFEATURE *feature ) { - FIXME("(%s %i %i %p): not implemented yet\n", - debugstr_w(feature->Feature), iCostTree, iState, piCost); - if (piCost) *piCost = 0; + 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 (;;) + { + MSIFEATURE *parent = get_loaded_feature( package, feature_parent ); + 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; return ERROR_SUCCESS; } diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 9f029f3d0d0..d1e8113423f 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -381,7 +381,6 @@ typedef struct tagMSIFEATURE INSTALLSTATE Action; struct list Children; struct list Components; - INT Cost; } MSIFEATURE; typedef struct tagMSICOMPONENT