msi: Create macro functions to set feature and component states.

This commit is contained in:
Mike McCormack 2006-10-26 12:34:52 +09:00 committed by Alexandre Julliard
parent 62aedea856
commit 6395ff6a5c

View File

@ -1696,12 +1696,24 @@ static BOOL process_state_property (MSIPACKAGE* package, LPCWSTR property,
break; break;
} }
} }
} }
msi_free(override); msi_free(override);
return TRUE; return TRUE;
} }
static void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state )
{
feature->ActionRequest = state;
feature->Action = state;
}
static void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state )
{
comp->ActionRequest = state;
comp->Action = state;
}
UINT MSI_SetFeatureStates(MSIPACKAGE *package) UINT MSI_SetFeatureStates(MSIPACKAGE *package)
{ {
int install_level; int install_level;
@ -1740,7 +1752,7 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
* 11) FILEADDDEFAULT * 11) FILEADDDEFAULT
* I have confirmed that if ADDLOCAL is stated then the INSTALLLEVEL is * I have confirmed that if ADDLOCAL is stated then the INSTALLLEVEL is
* ignored for all the features. seems strange, especially since it is not * ignored for all the features. seems strange, especially since it is not
* documented anywhere, but it is how it works. * documented anywhere, but it is how it works.
* *
* I am still ignoring a lot of these. But that is ok for now, ADDLOCAL and * I am still ignoring a lot of these. But that is ok for now, ADDLOCAL and
* REMOVE are the big ones, since we don't handle administrative installs * REMOVE are the big ones, since we don't handle administrative installs
@ -1760,20 +1772,11 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
if ((feature_state) && (feature->Action == INSTALLSTATE_UNKNOWN)) if ((feature_state) && (feature->Action == INSTALLSTATE_UNKNOWN))
{ {
if (feature->Attributes & msidbFeatureAttributesFavorSource) if (feature->Attributes & msidbFeatureAttributesFavorSource)
{ msi_feature_set_state( feature, INSTALLSTATE_SOURCE );
feature->ActionRequest = INSTALLSTATE_SOURCE;
feature->Action = INSTALLSTATE_SOURCE;
}
else if (feature->Attributes & msidbFeatureAttributesFavorAdvertise) else if (feature->Attributes & msidbFeatureAttributesFavorAdvertise)
{ msi_feature_set_state( feature, INSTALLSTATE_ADVERTISED );
feature->ActionRequest = INSTALLSTATE_ADVERTISED;
feature->Action = INSTALLSTATE_ADVERTISED;
}
else else
{ msi_feature_set_state( feature, INSTALLSTATE_LOCAL );
feature->ActionRequest = INSTALLSTATE_LOCAL;
feature->Action = INSTALLSTATE_LOCAL;
}
} }
} }
@ -1786,10 +1789,7 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
continue; continue;
LIST_FOR_EACH_ENTRY( fl, &feature->Children, FeatureList, entry ) LIST_FOR_EACH_ENTRY( fl, &feature->Children, FeatureList, entry )
{ msi_feature_set_state( fl->feature, INSTALLSTATE_UNKNOWN );
fl->feature->ActionRequest = INSTALLSTATE_UNKNOWN;
fl->feature->Action = INSTALLSTATE_UNKNOWN;
}
} }
} }
else else
@ -1802,8 +1802,8 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
} }
/* /*
* now we want to enable or disable components base on feature * now we want to enable or disable components base on feature
*/ */
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry ) LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
{ {
@ -1820,92 +1820,59 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
switch (component->Attributes) switch (component->Attributes)
{ {
case msidbComponentAttributesLocalOnly: case msidbComponentAttributesLocalOnly:
component->Action = INSTALLSTATE_LOCAL; msi_component_set_state( component, INSTALLSTATE_LOCAL );
component->ActionRequest = INSTALLSTATE_LOCAL;
break; break;
case msidbComponentAttributesSourceOnly: case msidbComponentAttributesSourceOnly:
component->Action = INSTALLSTATE_SOURCE; msi_component_set_state( component, INSTALLSTATE_SOURCE );
component->ActionRequest = INSTALLSTATE_SOURCE;
break; break;
case msidbComponentAttributesOptional: case msidbComponentAttributesOptional:
component->Action = INSTALLSTATE_DEFAULT; msi_component_set_state( component, INSTALLSTATE_DEFAULT );
component->ActionRequest = INSTALLSTATE_DEFAULT;
break; break;
default: default:
component->Action = INSTALLSTATE_LOCAL; msi_component_set_state( component, INSTALLSTATE_LOCAL );
component->ActionRequest = INSTALLSTATE_LOCAL;
} }
if (component->ForceLocalState) if (component->ForceLocalState)
{ msi_component_set_state( component, INSTALLSTATE_LOCAL );
component->Action = INSTALLSTATE_LOCAL;
component->ActionRequest = INSTALLSTATE_LOCAL;
}
if (!component->Enabled) if (!component->Enabled)
msi_component_set_state( component, INSTALLSTATE_UNKNOWN );
else if (feature->Attributes == msidbFeatureAttributesFavorLocal)
{ {
component->Action = INSTALLSTATE_UNKNOWN; if (!(component->Attributes & msidbComponentAttributesSourceOnly))
component->ActionRequest = INSTALLSTATE_UNKNOWN; msi_component_set_state( component, INSTALLSTATE_LOCAL );
} }
else else if (feature->Attributes == msidbFeatureAttributesFavorSource)
{ {
if (feature->Attributes == msidbFeatureAttributesFavorLocal) if ((component->Action == INSTALLSTATE_UNKNOWN) ||
{ (component->Action == INSTALLSTATE_ABSENT) ||
if (!(component->Attributes & msidbComponentAttributesSourceOnly)) (component->Action == INSTALLSTATE_ADVERTISED) ||
{ (component->Action == INSTALLSTATE_DEFAULT))
component->Action = INSTALLSTATE_LOCAL; msi_component_set_state( component, INSTALLSTATE_SOURCE );
component->ActionRequest = INSTALLSTATE_LOCAL;
}
}
else if (feature->Attributes == msidbFeatureAttributesFavorSource)
{
if ((component->Action == INSTALLSTATE_UNKNOWN) ||
(component->Action == INSTALLSTATE_ABSENT) ||
(component->Action == INSTALLSTATE_ADVERTISED) ||
(component->Action == INSTALLSTATE_DEFAULT))
{
component->Action = INSTALLSTATE_SOURCE;
component->ActionRequest = INSTALLSTATE_SOURCE;
}
}
else if (feature->ActionRequest == INSTALLSTATE_ADVERTISED)
{
if ((component->Action == INSTALLSTATE_UNKNOWN) ||
(component->Action == INSTALLSTATE_ABSENT))
{
component->Action = INSTALLSTATE_ADVERTISED;
component->ActionRequest = INSTALLSTATE_ADVERTISED;
}
}
else if (feature->ActionRequest == INSTALLSTATE_ABSENT)
{
if (component->Action == INSTALLSTATE_UNKNOWN)
{
component->Action = INSTALLSTATE_ABSENT;
component->ActionRequest = INSTALLSTATE_ABSENT;
}
}
else if (feature->ActionRequest == INSTALLSTATE_UNKNOWN)
{
component->Action = INSTALLSTATE_UNKNOWN;
component->ActionRequest = INSTALLSTATE_UNKNOWN;
}
} }
else if (feature->ActionRequest == INSTALLSTATE_ADVERTISED)
{
if ((component->Action == INSTALLSTATE_UNKNOWN) ||
(component->Action == INSTALLSTATE_ABSENT))
msi_component_set_state( component, INSTALLSTATE_ADVERTISED );
}
else if (feature->ActionRequest == INSTALLSTATE_ABSENT)
{
if (component->Action == INSTALLSTATE_UNKNOWN)
msi_component_set_state( component, INSTALLSTATE_ABSENT );
}
else if (feature->ActionRequest == INSTALLSTATE_UNKNOWN)
msi_component_set_state( component, INSTALLSTATE_UNKNOWN );
if (component->ForceLocalState && feature->Action == INSTALLSTATE_SOURCE) if (component->ForceLocalState && feature->Action == INSTALLSTATE_SOURCE)
{ msi_feature_set_state( feature, INSTALLSTATE_LOCAL );
feature->Action = INSTALLSTATE_LOCAL;
feature->ActionRequest = INSTALLSTATE_LOCAL;
}
} }
} }
LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry ) LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
{ {
TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n", TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n",
debugstr_w(component->Component), component->Installed, debugstr_w(component->Component), component->Installed,
component->Action, component->ActionRequest); component->Action, component->ActionRequest);
} }