From 575cc67d0fa56855e8b7460f85ba83b41538160c Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Thu, 26 Oct 2006 14:09:29 +0900 Subject: [PATCH] msi: Use msi_feature_set_state and msi_component_set_state where possible. --- dlls/msi/action.c | 28 +++++----------------------- dlls/msi/dialog.c | 3 +-- dlls/msi/events.c | 17 +++++------------ dlls/msi/helpers.c | 28 ++++++---------------------- dlls/msi/install.c | 3 +-- dlls/msi/msipriv.h | 12 ++++++++++++ 6 files changed, 30 insertions(+), 61 deletions(-) diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 3000ca000e2..161a2d66acf 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -1150,8 +1150,7 @@ static UINT load_component( MSIRECORD *row, LPVOID param ) comp->KeyPath = msi_dup_record_field( row, 6 ); comp->Installed = INSTALLSTATE_UNKNOWN; - comp->Action = INSTALLSTATE_UNKNOWN; - comp->ActionRequest = INSTALLSTATE_UNKNOWN; + msi_component_set_state( comp, INSTALLSTATE_UNKNOWN ); return ERROR_SUCCESS; } @@ -1282,8 +1281,7 @@ static UINT load_feature(MSIRECORD * row, LPVOID param) feature->Attributes = MSI_RecordGetInteger(row,8); feature->Installed = INSTALLSTATE_UNKNOWN; - feature->Action = INSTALLSTATE_UNKNOWN; - feature->ActionRequest = INSTALLSTATE_UNKNOWN; + msi_feature_set_state( feature, INSTALLSTATE_UNKNOWN ); list_add_tail( &package->features, &feature->entry ); @@ -1665,14 +1663,11 @@ static BOOL process_state_property (MSIPACKAGE* package, LPCWSTR property, override = msi_dup_property( package, property ); if (!override) return FALSE; - + LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry ) { if (strcmpiW(override,all)==0) - { - feature->ActionRequest= state; - feature->Action = state; - } + msi_feature_set_state( feature, state ); else { LPWSTR ptr = override; @@ -1683,8 +1678,7 @@ static BOOL process_state_property (MSIPACKAGE* package, LPCWSTR property, if ((ptr2 && strncmpW(ptr,feature->Feature, ptr2-ptr)==0) || (!ptr2 && strcmpW(ptr,feature->Feature)==0)) { - feature->ActionRequest= state; - feature->Action = state; + msi_feature_set_state( feature, state ); break; } if (ptr2) @@ -1702,18 +1696,6 @@ static BOOL process_state_property (MSIPACKAGE* package, LPCWSTR property, 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) { int install_level; diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c index 422f0c58fed..403e65f69dc 100644 --- a/dlls/msi/dialog.c +++ b/dlls/msi/dialog.c @@ -1766,8 +1766,7 @@ msi_seltree_menu( HWND hwnd, HTREEITEM hItem ) case INSTALLSTATE_LOCAL: case INSTALLSTATE_ADVERTISED: case INSTALLSTATE_ABSENT: - feature->ActionRequest = r; - feature->Action = r; + msi_feature_set_state( feature, r ); break; default: FIXME("select feature and all children\n"); diff --git a/dlls/msi/events.c b/dlls/msi/events.c index 2b0397bf73c..13805a66484 100644 --- a/dlls/msi/events.c +++ b/dlls/msi/events.c @@ -185,10 +185,8 @@ static UINT ControlEvent_AddLocal(MSIPACKAGE* package, LPCWSTR argument, else { LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry ) - { - feature->ActionRequest = INSTALLSTATE_LOCAL; - feature->Action = INSTALLSTATE_LOCAL; - } + msi_feature_set_state( feature, INSTALLSTATE_LOCAL ); + ACTION_UpdateComponentStates(package,argument); } return ERROR_SUCCESS; @@ -207,10 +205,8 @@ static UINT ControlEvent_Remove(MSIPACKAGE* package, LPCWSTR argument, else { LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry ) - { - feature->ActionRequest = INSTALLSTATE_ABSENT; - feature->Action= INSTALLSTATE_ABSENT; - } + msi_feature_set_state( feature, INSTALLSTATE_ABSENT ); + ACTION_UpdateComponentStates(package,argument); } return ERROR_SUCCESS; @@ -229,10 +225,7 @@ static UINT ControlEvent_AddSource(MSIPACKAGE* package, LPCWSTR argument, else { LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry ) - { - feature->ActionRequest = INSTALLSTATE_SOURCE; - feature->Action = INSTALLSTATE_SOURCE; - } + msi_feature_set_state( feature, INSTALLSTATE_SOURCE ); ACTION_UpdateComponentStates(package,argument); } return ERROR_SUCCESS; diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c index bb4dcc4b327..83a9f30214f 100644 --- a/dlls/msi/helpers.c +++ b/dlls/msi/helpers.c @@ -865,17 +865,13 @@ void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature) continue; if (newstate == INSTALLSTATE_LOCAL) - { - component->ActionRequest = INSTALLSTATE_LOCAL; - component->Action = INSTALLSTATE_LOCAL; - } + msi_component_set_state( component, INSTALLSTATE_LOCAL ); else { ComponentList *clist; MSIFEATURE *f; - component->ActionRequest = newstate; - component->Action = newstate; + msi_component_set_state( component, newstate ); /*if any other feature wants is local we need to set it local*/ LIST_FOR_EACH_ENTRY( f, &package->features, MSIFEATURE, entry ) @@ -897,26 +893,14 @@ void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature) if (component->Attributes & msidbComponentAttributesOptional) { if (f->Attributes & msidbFeatureAttributesFavorSource) - { - component->Action = INSTALLSTATE_SOURCE; - component->ActionRequest = INSTALLSTATE_SOURCE; - } + msi_component_set_state( component, INSTALLSTATE_SOURCE ); else - { - component->Action = INSTALLSTATE_LOCAL; - component->ActionRequest = INSTALLSTATE_LOCAL; - } + msi_component_set_state( component, INSTALLSTATE_LOCAL ); } else if (component->Attributes & msidbComponentAttributesSourceOnly) - { - component->Action = INSTALLSTATE_SOURCE; - component->ActionRequest = INSTALLSTATE_SOURCE; - } + msi_component_set_state( component, INSTALLSTATE_SOURCE ); else - { - component->Action = INSTALLSTATE_LOCAL; - component->ActionRequest = INSTALLSTATE_LOCAL; - } + msi_component_set_state( component, INSTALLSTATE_LOCAL ); } } } diff --git a/dlls/msi/install.c b/dlls/msi/install.c index 7a367aa1cb2..fdec30c9995 100644 --- a/dlls/msi/install.c +++ b/dlls/msi/install.c @@ -539,8 +539,7 @@ UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE* package, LPCWSTR szFeature, feature->Attributes & msidbFeatureAttributesDisallowAdvertise) return ERROR_FUNCTION_FAILED; - feature->ActionRequest = iState; - feature->Action = iState; + msi_feature_set_state( feature, iState ); ACTION_UpdateComponentStates(package,szFeature); diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 5acdd256de9..cdb95c4c9fb 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -713,6 +713,18 @@ extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action); extern void ACTION_FinishCustomActions( MSIPACKAGE* package); extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, BOOL execute); +static inline void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state ) +{ + feature->ActionRequest = state; + feature->Action = state; +} + +static inline void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state ) +{ + comp->ActionRequest = state; + comp->Action = state; +} + /* actions in other modules */ extern UINT ACTION_AppSearch(MSIPACKAGE *package); extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package); -- 2.11.4.GIT