James Hawkins : msi: Publish the UpgradeCode in PublishProduct.

Alexandre Julliard julliard at winehq.org
Tue Jun 24 06:45:52 CDT 2008


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

Author: James Hawkins <jhawkins at codeweavers.com>
Date:   Mon Jun 23 23:02:54 2008 -0500

msi: Publish the UpgradeCode in PublishProduct.

---

 dlls/msi/action.c           |   68 ++++++++++++++++++++++++++++++++++---------
 dlls/msi/msipriv.h          |    1 +
 dlls/msi/registry.c         |   15 +++++++++
 dlls/msi/tests/automation.c |    5 +--
 dlls/msi/tests/install.c    |    7 +---
 5 files changed, 73 insertions(+), 23 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 33ce25c..6761b39 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -3473,6 +3473,34 @@ done:
     return ERROR_SUCCESS;
 }
 
+static UINT msi_publish_upgrade_code(MSIPACKAGE *package)
+{
+    UINT r;
+    HKEY hkey;
+    LPWSTR upgrade;
+    WCHAR squashed_pc[SQUISH_GUID_SIZE];
+
+    static const WCHAR szUpgradeCode[] =
+        {'U','p','g','r','a','d','e','C','o','d','e',0};
+
+    upgrade = msi_dup_property(package, szUpgradeCode);
+    if (!upgrade)
+        return ERROR_SUCCESS;
+
+    r = MSIREG_OpenUserUpgradeCodesKey(upgrade, &hkey, TRUE);
+    if (r != ERROR_SUCCESS)
+        goto done;
+
+    squash_guid(package->ProductCode, squashed_pc);
+    msi_reg_set_val_str(hkey, squashed_pc, NULL);
+
+    RegCloseKey(hkey);
+
+done:
+    msi_free(upgrade);
+    return r;
+}
+
 static BOOL msi_check_publish(MSIPACKAGE *package)
 {
     MSIFEATURE *feature;
@@ -3486,6 +3514,19 @@ static BOOL msi_check_publish(MSIPACKAGE *package)
     return FALSE;
 }
 
+static BOOL msi_check_unpublish(MSIPACKAGE *package)
+{
+    MSIFEATURE *feature;
+
+    LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
+    {
+        if (feature->ActionRequest != INSTALLSTATE_ABSENT)
+            return FALSE;
+    }
+
+    return TRUE;
+}
+
 /*
  * 99% of the work done here is only done for 
  * advertised installs. However this is where the
@@ -3531,7 +3572,9 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
     if (rc != ERROR_SUCCESS)
         goto end;
 
-    /* FIXME: Need to write more keys to the user registry */
+    rc = msi_publish_upgrade_code(package);
+    if (rc != ERROR_SUCCESS)
+        goto end;
 
     rc = msi_publish_product_properties(package, hukey);
     if (rc != ERROR_SUCCESS)
@@ -3895,19 +3938,6 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
     return ERROR_SUCCESS;
 }
 
-static BOOL msi_check_unpublish(MSIPACKAGE *package)
-{
-    MSIFEATURE *feature;
-
-    LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
-    {
-        if (feature->ActionRequest != INSTALLSTATE_ABSENT)
-            return FALSE;
-    }
-
-    return TRUE;
-}
-
 static UINT ACTION_UnpublishFeatures(MSIPACKAGE *package)
 {
     MSIFEATURE *feature;
@@ -4152,6 +4182,7 @@ static UINT ACTION_InstallExecute(MSIPACKAGE *package)
 
 static UINT msi_unpublish_product(MSIPACKAGE *package)
 {
+    LPWSTR upgrade;
     LPWSTR remove = NULL;
     LPWSTR *features = NULL;
     BOOL full_uninstall = TRUE;
@@ -4159,6 +4190,8 @@ static UINT msi_unpublish_product(MSIPACKAGE *package)
 
     static const WCHAR szRemove[] = {'R','E','M','O','V','E',0};
     static const WCHAR szAll[] = {'A','L','L',0};
+    static const WCHAR szUpgradeCode[] =
+        {'U','p','g','r','a','d','e','C','o','d','e',0};
 
     remove = msi_dup_property(package, szRemove);
     if (!remove)
@@ -4192,6 +4225,13 @@ static UINT msi_unpublish_product(MSIPACKAGE *package)
     MSIREG_DeleteUserFeaturesKey(package->ProductCode);
     MSIREG_DeleteUninstallKey(package->ProductCode);
 
+    upgrade = msi_dup_property(package, szUpgradeCode);
+    if (upgrade)
+    {
+        MSIREG_DeleteUserUpgradeCodesKey(upgrade);
+        msi_free(upgrade);
+    }
+
 done:
     msi_free(remove);
     msi_free(features);
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index b045710..e2c18e4 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -791,6 +791,7 @@ extern UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BO
 extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
 extern UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent);
 extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
+extern UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode);
 
 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index 7b586a8..c3d425d 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -980,6 +980,21 @@ UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL creat
     return rc;
 }
 
+UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode)
+{
+    WCHAR squished_pc[GUID_SIZE];
+    WCHAR keypath[0x200];
+
+    TRACE("%s\n",debugstr_w(szUpgradeCode));
+    if (!squash_guid(szUpgradeCode,squished_pc))
+        return ERROR_FUNCTION_FAILED;
+    TRACE("squished (%s)\n", debugstr_w(squished_pc));
+
+    sprintfW(keypath,szInstaller_UserUpgradeCodes_fmt,squished_pc);
+
+    return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
+}
+
 UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
 {
     WCHAR squished_pc[GUID_SIZE];
diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c
index ec54065..68b0f75 100644
--- a/dlls/msi/tests/automation.c
+++ b/dlls/msi/tests/automation.c
@@ -2301,10 +2301,7 @@ static void test_Installer_InstallProduct(void)
     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
 
     res = RegDeleteKeyA(hkey, "UpgradeCodes\\D8E760ECA1E276347B43E42BDBDA5656");
-    todo_wine
-    {
-        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
-    }
+    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
 
     RegCloseKey(hkey);
 
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 7778a96..773eaaf 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -2569,12 +2569,9 @@ static void test_publish_publishproduct(void)
     RegCloseKey(hkey);
 
     res = RegOpenKeyA(HKEY_CURRENT_USER, cuupgrades, &hkey);
-    todo_wine
-    {
-        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
 
-        CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
-    }
+    CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
 
     RegDeleteKeyA(hkey, "");
     RegCloseKey(hkey);




More information about the wine-cvs mailing list