Mike McCormack : msi: Use msi_feature_set_state and msi_component_set_state where possible.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Oct 26 06:31:38 CDT 2006


Module: wine
Branch: master
Commit: 575cc67d0fa56855e8b7460f85ba83b41538160c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=575cc67d0fa56855e8b7460f85ba83b41538160c

Author: Mike McCormack <mike at codeweavers.com>
Date:   Thu Oct 26 14:09:29 2006 +0900

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 3000ca0..161a2d6 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -1150,8 +1150,7 @@ static UINT load_component( MSIRECORD *r
     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
     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 (MSIP
     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 (MSIP
                 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 (MSIP
     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 422f0c5..403e65f 100644
--- a/dlls/msi/dialog.c
+++ b/dlls/msi/dialog.c
@@ -1766,8 +1766,7 @@ msi_seltree_menu( HWND hwnd, HTREEITEM h
     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 2b0397b..13805a6 100644
--- a/dlls/msi/events.c
+++ b/dlls/msi/events.c
@@ -185,10 +185,8 @@ static UINT ControlEvent_AddLocal(MSIPAC
     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(MSIPACKA
     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(MSIPA
     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 bb4dcc4..83a9f30 100644
--- a/dlls/msi/helpers.c
+++ b/dlls/msi/helpers.c
@@ -865,17 +865,13 @@ void ACTION_UpdateComponentStates(MSIPAC
             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(MSIPAC
                         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 7a367aa..fdec30c 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -539,8 +539,7 @@ UINT WINAPI MSI_SetFeatureStateW(MSIPACK
         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 5acdd25..cdb95c4 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -713,6 +713,18 @@ extern UINT ACTION_PerformUIAction(MSIPA
 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);




More information about the wine-cvs mailing list