2005-06-09 12:05:27 +00:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-06-09 12:05:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actions focused on in this module
|
|
|
|
*
|
|
|
|
* FindRelatedProducts
|
|
|
|
* MigrateFeatureStates (TODO)
|
|
|
|
* RemoveExistingProducts (TODO)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msidefs.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
static BOOL check_language(DWORD lang1, LPCWSTR lang2, DWORD attributes)
|
|
|
|
{
|
|
|
|
DWORD langdword;
|
|
|
|
|
|
|
|
if (!lang2 || lang2[0]==0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
langdword = atoiW(lang2);
|
|
|
|
|
|
|
|
if (attributes & msidbUpgradeAttributesLanguagesExclusive)
|
|
|
|
return (lang1 != langdword);
|
|
|
|
else
|
|
|
|
return (lang1 == langdword);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void append_productcode(MSIPACKAGE* package, LPCWSTR action_property,
|
|
|
|
LPCWSTR productid)
|
|
|
|
{
|
|
|
|
LPWSTR prop;
|
|
|
|
LPWSTR newprop;
|
|
|
|
DWORD len;
|
|
|
|
|
2005-09-15 15:04:08 +00:00
|
|
|
prop = msi_dup_property(package, action_property );
|
2005-06-09 12:05:27 +00:00
|
|
|
if (prop)
|
|
|
|
len = strlenW(prop);
|
|
|
|
else
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
/*separator*/
|
|
|
|
len ++;
|
|
|
|
|
|
|
|
len += strlenW(productid);
|
|
|
|
|
|
|
|
/*null*/
|
|
|
|
len++;
|
|
|
|
|
2005-09-20 11:57:19 +00:00
|
|
|
newprop = msi_alloc( len*sizeof(WCHAR) );
|
2005-06-09 12:05:27 +00:00
|
|
|
|
|
|
|
if (prop)
|
|
|
|
{
|
|
|
|
strcpyW(newprop,prop);
|
2009-10-15 10:46:27 +00:00
|
|
|
strcatW(newprop,szSemiColon);
|
2005-06-09 12:05:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
newprop[0] = 0;
|
|
|
|
strcatW(newprop,productid);
|
|
|
|
|
|
|
|
MSI_SetPropertyW(package, action_property, newprop);
|
|
|
|
TRACE("Found Related Product... %s now %s\n",debugstr_w(action_property),
|
|
|
|
debugstr_w(newprop));
|
2005-09-20 11:57:19 +00:00
|
|
|
msi_free( prop );
|
|
|
|
msi_free( newprop );
|
2005-06-09 12:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
|
|
|
|
{
|
2009-01-15 08:46:57 +00:00
|
|
|
MSIPACKAGE *package = param;
|
2005-06-09 12:05:27 +00:00
|
|
|
WCHAR product[GUID_SIZE];
|
|
|
|
DWORD index = 0;
|
|
|
|
DWORD attributes = 0;
|
|
|
|
DWORD sz = GUID_SIZE;
|
|
|
|
LPCWSTR upgrade_code;
|
|
|
|
HKEY hkey = 0;
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
2005-06-16 16:08:58 +00:00
|
|
|
MSIRECORD *uirow;
|
2005-06-09 12:05:27 +00:00
|
|
|
|
|
|
|
upgrade_code = MSI_RecordGetString(rec,1);
|
|
|
|
|
|
|
|
rc = MSIREG_OpenUpgradeCodesKey(upgrade_code, &hkey, FALSE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2005-06-16 16:08:58 +00:00
|
|
|
uirow = MSI_CreateRecord(1);
|
2005-06-09 12:05:27 +00:00
|
|
|
attributes = MSI_RecordGetInteger(rec,5);
|
2009-03-22 21:30:16 +00:00
|
|
|
|
2005-06-09 12:05:27 +00:00
|
|
|
while (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = RegEnumValueW(hkey, index, product, &sz, NULL, NULL, NULL, NULL);
|
2006-10-05 04:41:22 +00:00
|
|
|
TRACE("Looking at (%i) %s\n",index,debugstr_w(product));
|
2005-06-09 12:05:27 +00:00
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR productid[GUID_SIZE];
|
|
|
|
LPCWSTR ver;
|
|
|
|
LPCWSTR language;
|
|
|
|
LPCWSTR action_property;
|
|
|
|
DWORD check = 0x00000000;
|
|
|
|
DWORD comp_ver = 0x00000000;
|
|
|
|
DWORD sz = 0x100;
|
|
|
|
HKEY hukey;
|
|
|
|
INT r;
|
|
|
|
|
2008-11-04 04:16:43 +00:00
|
|
|
unsquash_guid(product, productid);
|
2009-03-22 21:30:16 +00:00
|
|
|
rc = MSIREG_OpenProductKey(productid, NULL, package->Context,
|
2008-11-04 04:16:43 +00:00
|
|
|
&hukey, FALSE);
|
2005-06-09 12:05:27 +00:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
2008-11-04 04:16:43 +00:00
|
|
|
|
2005-06-09 12:05:27 +00:00
|
|
|
sz = sizeof(DWORD);
|
2005-07-13 12:07:41 +00:00
|
|
|
RegQueryValueExW(hukey, INSTALLPROPERTY_VERSIONW, NULL, NULL,
|
2005-07-11 18:01:39 +00:00
|
|
|
(LPBYTE)&check, &sz);
|
2005-06-09 12:05:27 +00:00
|
|
|
/* check min */
|
|
|
|
ver = MSI_RecordGetString(rec,2);
|
2006-07-14 06:19:08 +00:00
|
|
|
comp_ver = msi_version_str_to_dword(ver);
|
2005-06-09 12:05:27 +00:00
|
|
|
r = check - comp_ver;
|
|
|
|
if (r < 0 || (r == 0 && !(attributes &
|
|
|
|
msidbUpgradeAttributesVersionMinInclusive)))
|
|
|
|
{
|
|
|
|
RegCloseKey(hukey);
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check max */
|
|
|
|
ver = MSI_RecordGetString(rec,3);
|
2006-07-14 06:19:08 +00:00
|
|
|
comp_ver = msi_version_str_to_dword(ver);
|
2005-06-09 12:05:27 +00:00
|
|
|
r = check - comp_ver;
|
|
|
|
if (r > 0 || (r == 0 && !(attributes &
|
|
|
|
msidbUpgradeAttributesVersionMaxInclusive)))
|
|
|
|
{
|
|
|
|
RegCloseKey(hukey);
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check language*/
|
|
|
|
sz = sizeof(DWORD);
|
2005-07-13 12:07:41 +00:00
|
|
|
RegQueryValueExW(hukey, INSTALLPROPERTY_LANGUAGEW, NULL, NULL,
|
2005-07-11 18:01:39 +00:00
|
|
|
(LPBYTE)&check, &sz);
|
2005-06-09 12:05:27 +00:00
|
|
|
RegCloseKey(hukey);
|
|
|
|
language = MSI_RecordGetString(rec,4);
|
2006-10-05 04:41:22 +00:00
|
|
|
TRACE("Checking languages %x and %s\n", check,
|
2005-06-09 12:05:27 +00:00
|
|
|
debugstr_w(language));
|
|
|
|
if (!check_language(check, language, attributes))
|
|
|
|
{
|
|
|
|
index ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-03-05 11:25:31 +00:00
|
|
|
action_property = MSI_RecordGetString(rec, 7);
|
|
|
|
append_productcode(package, action_property, productid);
|
|
|
|
MSI_RecordSetStringW(uirow, 1, productid);
|
|
|
|
ui_actiondata(package, szFindRelatedProducts, uirow);
|
2005-06-09 12:05:27 +00:00
|
|
|
}
|
|
|
|
index ++;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
2005-06-16 16:08:58 +00:00
|
|
|
msiobj_release( &uirow->hdr);
|
2005-06-09 12:05:27 +00:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT ACTION_FindRelatedProducts(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
static const WCHAR Query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',
|
|
|
|
' ','`','U','p','g','r','a','d','e','`',0};
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
2010-03-02 13:58:27 +00:00
|
|
|
if (msi_get_property_int(package, szInstalled, 0))
|
|
|
|
{
|
|
|
|
TRACE("Skipping FindRelatedProducts action: product already installed\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-03-23 10:46:00 +00:00
|
|
|
if (check_unique_action(package, szFindRelatedProducts))
|
2005-06-30 20:45:43 +00:00
|
|
|
{
|
2010-03-23 10:46:00 +00:00
|
|
|
TRACE("Skipping FindRelatedProducts action: already done in UI sequence\n");
|
2005-06-09 12:05:27 +00:00
|
|
|
return ERROR_SUCCESS;
|
2005-06-30 20:45:43 +00:00
|
|
|
}
|
|
|
|
else
|
2010-03-23 10:46:00 +00:00
|
|
|
register_unique_action(package, szFindRelatedProducts);
|
2005-06-09 12:05:27 +00:00
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_FindRelatedProducts, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|