Mike McCormack : msi: Always load all the components.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jul 26 04:22:45 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 1d46cdf11af912f4ec1b4f390fc1844605be2ce5
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=1d46cdf11af912f4ec1b4f390fc1844605be2ce5

Author: Mike McCormack <mike at codeweavers.com>
Date:   Tue Jul 25 21:49:44 2006 +0900

msi: Always load all the components.

---

 dlls/msi/action.c        |  141 ++++++++++++++++++++++------------------------
 dlls/msi/tests/install.c |    5 --
 dlls/msi/tests/package.c |    2 -
 3 files changed, 68 insertions(+), 80 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 2479f2e..f7454c2 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -1095,13 +1095,16 @@ static UINT ACTION_CreateFolders(MSIPACK
     return rc;
 }
 
-static MSICOMPONENT* load_component( MSIRECORD * row )
+static UINT load_component( MSIRECORD *row, LPVOID param )
 {
+    MSIPACKAGE *package = param;
     MSICOMPONENT *comp;
 
     comp = msi_alloc_zero( sizeof(MSICOMPONENT) );
     if (!comp)
-        return comp;
+        return ERROR_FUNCTION_FAILED;
+
+    list_add_tail( &package->components, &comp->entry );
 
     /* fill in the data */
     comp->Component = msi_dup_record_field( row, 1 );
@@ -1118,26 +1121,41 @@ static MSICOMPONENT* load_component( MSI
 
     switch (comp->Attributes)
     {
-        case msidbComponentAttributesLocalOnly:
-            comp->Action = INSTALLSTATE_LOCAL;
-            comp->ActionRequest = INSTALLSTATE_LOCAL;
-            break;
-        case msidbComponentAttributesSourceOnly:
-            comp->Action = INSTALLSTATE_SOURCE;
-            comp->ActionRequest = INSTALLSTATE_SOURCE;
-            break;
-        case msidbComponentAttributesOptional:
-            comp->Action = INSTALLSTATE_LOCAL;
-            comp->ActionRequest = INSTALLSTATE_LOCAL;
-            break;
-        default:
-            comp->Action = INSTALLSTATE_UNKNOWN;
-            comp->ActionRequest = INSTALLSTATE_UNKNOWN;
+    case msidbComponentAttributesLocalOnly:
+    case msidbComponentAttributesOptional:
+        comp->Action = INSTALLSTATE_LOCAL;
+        comp->ActionRequest = INSTALLSTATE_LOCAL;
+        break;
+    case msidbComponentAttributesSourceOnly:
+        comp->Action = INSTALLSTATE_SOURCE;
+        comp->ActionRequest = INSTALLSTATE_SOURCE;
+        break;
+    default:
+        comp->Action = INSTALLSTATE_UNKNOWN;
+        comp->ActionRequest = INSTALLSTATE_UNKNOWN;
     }
 
-    comp->Enabled = TRUE;
+    return ERROR_SUCCESS;
+}
+
+static UINT load_all_components( MSIPACKAGE *package )
+{
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ', 
+         '`','C','o','m','p','o','n','e','n','t','`',0 };
+    MSIQUERY *view;
+    UINT r;
+
+    if (!list_empty(&package->components))
+        return ERROR_SUCCESS;
 
-    return comp;
+    r = MSI_DatabaseOpenViewW( package->db, query, &view );
+    if (r != ERROR_SUCCESS)
+        return r;
+
+    r = MSI_IterateRecords(view, NULL, load_component, package);
+    msiobj_release(&view->hdr);
+    return r;
 }
 
 typedef struct {
@@ -1158,56 +1176,24 @@ static UINT add_feature_component( MSIFE
     return ERROR_SUCCESS;
 }
 
-static UINT iterate_component_check( MSIRECORD *row, LPVOID param )
-{
-    _ilfs* ilfs= (_ilfs*)param;
-    MSIPACKAGE *package = ilfs->package;
-    MSIFEATURE *feature = ilfs->feature;
-    MSICOMPONENT *comp;
-
-    comp = load_component( row );
-    if (!comp)
-        return ERROR_FUNCTION_FAILED;
-
-    list_add_tail( &package->components, &comp->entry );
-    add_feature_component( feature, comp );
-
-    TRACE("Loaded new component %p\n", comp);
-
-    return ERROR_SUCCESS;
-}
-
 static UINT iterate_load_featurecomponents(MSIRECORD *row, LPVOID param)
 {
     _ilfs* ilfs= (_ilfs*)param;
     LPCWSTR component;
-    DWORD rc;
     MSICOMPONENT *comp;
-    MSIQUERY * view;
-    static const WCHAR Query[] = 
-        {'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ', 
-         '`','C','o','m','p','o','n','e','n','t','`',' ',
-         'W','H','E','R','E',' ', 
-         '`','C','o','m','p','o','n','e','n','t','`',' ',
-         '=','\'','%','s','\'',0};
 
     component = MSI_RecordGetString(row,1);
 
     /* check to see if the component is already loaded */
     comp = get_loaded_component( ilfs->package, component );
-    if (comp)
+    if (!comp)
     {
-        TRACE("Component %s already loaded\n", debugstr_w(component) );
-        add_feature_component( ilfs->feature, comp );
-        return ERROR_SUCCESS;
+        ERR("unknown component %s\n", debugstr_w(component));
+        return ERROR_FUNCTION_FAILED;
     }
 
-    rc = MSI_OpenQuery(ilfs->package->db, &view, Query, component);
-    if (rc != ERROR_SUCCESS)
-        return ERROR_SUCCESS;
-
-    rc = MSI_IterateRecords(view, NULL, iterate_component_check, ilfs);
-    msiobj_release( &view->hdr );
+    add_feature_component( ilfs->feature, comp );
+    comp->Enabled = TRUE;
 
     return ERROR_SUCCESS;
 }
@@ -1271,6 +1257,27 @@ static UINT load_feature(MSIRECORD * row
     return ERROR_SUCCESS;
 }
 
+static UINT load_all_features( MSIPACKAGE *package )
+{
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
+        '`','F','e','a','t','u','r','e','`',' ','O','R','D','E','R',
+        ' ','B','Y',' ','`','D','i','s','p','l','a','y','`',0};
+    MSIQUERY *view;
+    UINT r;
+
+    if (!list_empty(&package->features))
+        return ERROR_SUCCESS;
+ 
+    r = MSI_DatabaseOpenViewW( package->db, query, &view );
+    if (r != ERROR_SUCCESS)
+        return r;
+
+    r = MSI_IterateRecords( view, NULL, load_feature, package );
+    msiobj_release( &view->hdr );
+    return r;
+}
+
 static LPWSTR folder_split_path(LPWSTR p, WCHAR ch)
 {
     if (!p)
@@ -1361,12 +1368,6 @@ static UINT load_all_files(MSIPACKAGE *p
  */
 static UINT ACTION_CostInitialize(MSIPACKAGE *package)
 {
-    MSIQUERY * view;
-    UINT rc;
-    static const WCHAR Query_all[] =
-        {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
-         '`','F','e','a','t','u','r','e','`',' ','O','R','D','E','R',
-         ' ','B','Y',' ','`','D','i','s','p','l','a','y','`',0};
     static const WCHAR szCosting[] =
         {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
     static const WCHAR szZero[] = { '0', 0 };
@@ -1375,19 +1376,11 @@ static UINT ACTION_CostInitialize(MSIPAC
         return ERROR_SUCCESS;
 
     MSI_SetPropertyW(package, szCosting, szZero);
-    MSI_SetPropertyW(package, cszRootDrive , c_colon);
-
-    rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view);
-    if (rc != ERROR_SUCCESS)
-        return rc;
-
-    if (list_empty(&package->features))
-    {
-        rc = MSI_IterateRecords(view, NULL, load_feature, package);
-        msiobj_release(&view->hdr);
-    }
+    MSI_SetPropertyW(package, cszRootDrive, c_colon);
 
-    load_all_files(package);
+    load_all_components( package );
+    load_all_features( package );
+    load_all_files( package );
 
     return ERROR_SUCCESS;
 }
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index dfd469b..8792629 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -661,10 +661,7 @@ static void test_MsiSetComponentState(vo
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
 
     r = MsiDoAction(package, "CostInitialize");
-    todo_wine
-    {
-        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
-    }
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
 
     r = MsiDoAction(package, "FileCost");
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index d44d981..f375260 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -315,10 +315,8 @@ static void test_getsourcepath( void )
     r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
     ok( r == ERROR_DIRECTORY, "return value wrong\n");
 
-    todo_wine {
     r = MsiDoAction( hpkg, "CostInitialize");
     ok( r == ERROR_SUCCESS, "cost init failed\n");
-    }
     r = MsiDoAction( hpkg, "CostFinalize");
     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
 




More information about the wine-cvs mailing list