msi 10: Delay publishing of the SourceList until the PublishProduct action

James Hawkins truiken at gmail.com
Wed Jun 27 22:20:14 CDT 2007


Hi,

Changelog:
* Delay publishing of the SourceList until the PublishProduct action.

 dlls/msi/action.c        |   17 +++++++++++++++++
 dlls/msi/files.c         |   18 +++++++-----------
 dlls/msi/helpers.c       |   17 +++++++++++++++++
 dlls/msi/msipriv.h       |   24 ++++++++++++++++++++++++
 dlls/msi/package.c       |   39 +++++++++++++++++++++++++++++++++++++++
 dlls/msi/tests/install.c |    7 ++-----
 6 files changed, 106 insertions(+), 16 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 092c5c3..ea13cba 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -3244,6 +3244,8 @@ static UINT ACTION_PublishProduct(MSIPAC
 {
     UINT rc;
     MSIQUERY * view;
+    MSISOURCELISTINFO *info;
+    MSIMEDIADISK *disk;
     static const WCHAR Query[]=
         {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
          '`','I','c','o','n','`',0};
@@ -3356,6 +3358,21 @@ static UINT ACTION_PublishProduct(MSIPAC
         rc = ERROR_SUCCESS;
     }
 
+    /* publish the SourceList info */
+    LIST_FOR_EACH_ENTRY(info, &package->sourcelist_info, MSISOURCELISTINFO, entry)
+    {
+        MsiSourceListSetInfoW(package->ProductCode, NULL,
+                              info->context, info->options,
+                              info->property, info->value);
+    }
+
+    LIST_FOR_EACH_ENTRY(disk, &package->sourcelist_media, MSIMEDIADISK, entry)
+    {
+        MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
+                                   disk->context, disk->options,
+                                   disk->disk_id, disk->volume_label, disk->disk_prompt);
+    }
+
 end:
     RegCloseKey(hkey);
     RegCloseKey(hukey);
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index 14fb83b..f2561d4 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -580,14 +580,12 @@ static UINT load_media_info(MSIPACKAGE *
             lstrcatW(mi->source, mi->cabinet);
     }
 
-    MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
-        MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
-        mi->disk_id, mi->volume_label, mi->disk_prompt);
+    msi_package_add_media_disk(package, MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT,
+                               mi->disk_id, mi->volume_label, mi->disk_prompt);
 
-    MsiSourceListSetInfoW(package->ProductCode, NULL,
-        MSIINSTALLCONTEXT_USERMANAGED,
-        MSICODE_PRODUCT | MSISOURCETYPE_MEDIA,
-        INSTALLPROPERTY_LASTUSEDSOURCEW, mi->source);
+    msi_package_add_info(package, MSIINSTALLCONTEXT_USERMANAGED,
+                         MSICODE_PRODUCT | MSISOURCETYPE_MEDIA,
+                         INSTALLPROPERTY_LASTUSEDSOURCEW, mi->source);
 
     msi_free(source_dir);
     return ERROR_SUCCESS;
@@ -754,10 +752,8 @@ UINT ACTION_InstallFiles(MSIPACKAGE *pac
     if (ptr)
     {
         ptr++;
-        MsiSourceListSetInfoW(package->ProductCode, NULL,
-                MSIINSTALLCONTEXT_USERMANAGED,
-                MSICODE_PRODUCT,
-                INSTALLPROPERTY_PACKAGENAMEW, ptr);
+        msi_package_add_info(package, MSIINSTALLCONTEXT_USERMANAGED,
+                             MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, ptr);
     }
 
     schedule_install_files(package);
diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c
index 36cbda4..f67c70d 100644
--- a/dlls/msi/helpers.c
+++ b/dlls/msi/helpers.c
@@ -607,6 +607,23 @@ void ACTION_free_package_structures( MSI
         msi_free( appid );
     }
 
+    LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_info )
+    {
+        MSISOURCELISTINFO *info = LIST_ENTRY( item, MSISOURCELISTINFO, entry );
+
+        list_remove( &info->entry );
+        msi_free( info->value );
+    }
+
+    LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_media )
+    {
+        MSIMEDIADISK *info = LIST_ENTRY( item, MSIMEDIADISK, entry );
+
+        list_remove( &info->entry );
+        msi_free( info->volume_label );
+        msi_free( info->disk_prompt );
+    }
+
     if (package->script)
     {
         for (i = 0; i < TOTAL_SCRIPTS; i++)
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 96ca048..b053912 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -113,6 +113,25 @@ typedef struct tagMSIRECORD
     MSIFIELD fields[1]; /* nb. array size is count+1 */
 } MSIRECORD;
 
+typedef struct tagMSISOURCELISTINFO
+{
+    struct list entry;
+    DWORD context;
+    DWORD options;
+    LPCWSTR property;
+    LPWSTR value;
+} MSISOURCELISTINFO;
+
+typedef struct tagMSIMEDIADISK
+{
+    struct list entry;
+    DWORD context;
+    DWORD options;
+    DWORD disk_id;
+    LPWSTR volume_label;
+    LPWSTR disk_prompt;
+} MSIMEDIADISK;
+
 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
 
 typedef struct tagMSIVIEWOPS
@@ -249,6 +268,9 @@ typedef struct tagMSIPACKAGE
 
     struct list subscriptions;
 
+    struct list sourcelist_info;
+    struct list sourcelist_media;
+
     unsigned char scheduled_action_running : 1;
     unsigned char commit_action_running : 1;
     unsigned char rollback_action_running : 1;
@@ -657,6 +679,8 @@ extern UINT MSI_GetComponentStateW( MSIP
 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
+extern UINT msi_package_add_info(MSIPACKAGE *, DWORD, DWORD, LPCWSTR, LPWSTR);
+extern UINT msi_package_add_media_disk(MSIPACKAGE *, DWORD, DWORD, DWORD, LPWSTR, LPWSTR);
 
 /* for deformating */
 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, DWORD * );
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index c53def9..ab6e9af 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -697,6 +697,8 @@ static MSIPACKAGE *msi_alloc_package( vo
         list_init( &package->extensions );
         list_init( &package->progids );
         list_init( &package->RunningActions );
+        list_init( &package->sourcelist_info );
+        list_init( &package->sourcelist_media );
 
         package->ActionFormat = NULL;
         package->LastAction = NULL;
@@ -1393,3 +1395,40 @@ UINT WINAPI MsiGetPropertyW( MSIHANDLE h
 
     return MSI_GetProperty( hInstall, szName, &val, pchValueBuf );
 }
+
+UINT msi_package_add_info(MSIPACKAGE *package, DWORD context, DWORD options,
+                          LPCWSTR property, LPWSTR value)
+{
+    MSISOURCELISTINFO *info;
+
+    info = msi_alloc(sizeof(MSISOURCELISTINFO));
+    if (!info)
+        return ERROR_OUTOFMEMORY;
+
+    info->context = context;
+    info->options = options;
+    info->property = property;
+    info->value = strdupW(value);
+    list_add_head(&package->sourcelist_info, &info->entry);
+
+    return ERROR_SUCCESS;
+}
+
+UINT msi_package_add_media_disk(MSIPACKAGE *package, DWORD context, DWORD options,
+                                DWORD disk_id, LPWSTR volume_label, LPWSTR disk_prompt)
+{
+    MSIMEDIADISK *disk;
+
+    disk = msi_alloc(sizeof(MSIMEDIADISK));
+    if (!disk)
+        return ERROR_OUTOFMEMORY;
+
+    disk->context = context;
+    disk->options = options;
+    disk->disk_id = disk_id;
+    disk->volume_label = strdupW(volume_label);
+    disk->disk_prompt = strdupW(disk_prompt);
+    list_add_head(&package->sourcelist_media, &disk->entry);
+
+    return ERROR_SUCCESS;
+}
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 7af097e..421fd85 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -2244,11 +2244,8 @@ static void test_publishsourcelist(void)
     r = MsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
-        ok(size == 11, "Expected 11, got %d\n", size);
-    }
+    ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
+    ok(size == 11, "Expected 11, got %d\n", size);
 
     /* complete uninstall */
     r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
-- 
1.4.1


More information about the wine-patches mailing list