msi: Add a partial implementation of the ValidateProductID standard action.

This commit is contained in:
Hans Leidekker 2010-02-10 11:55:59 +01:00 committed by Alexandre Julliard
parent 7331b3ca98
commit 068cb1291b
4 changed files with 118 additions and 10 deletions

View File

@ -6125,6 +6125,30 @@ done:
return r;
}
static UINT ACTION_ValidateProductID( MSIPACKAGE *package )
{
LPWSTR key, template, id;
UINT r = ERROR_SUCCESS;
id = msi_dup_property( package, szProductID );
if (id)
{
msi_free( id );
return ERROR_SUCCESS;
}
template = msi_dup_property( package, szPIDTemplate );
key = msi_dup_property( package, szPIDKEY );
if (key && template)
{
FIXME( "partial stub: template %s key %s\n", debugstr_w(template), debugstr_w(key) );
r = MSI_SetPropertyW( package, szProductID, key );
}
msi_free( template );
msi_free( key );
return r;
}
static UINT ACTION_ScheduleReboot( MSIPACKAGE *package )
{
TRACE("\n");
@ -6206,13 +6230,6 @@ static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package )
return msi_unimplemented_action_stub( package, "MigrateFeatureStates", table );
}
static UINT ACTION_ValidateProductID( MSIPACKAGE *package )
{
static const WCHAR table[] = {
'P','r','o','d','u','c','t','I','D',0 };
return msi_unimplemented_action_stub( package, "ValidateProductID", table );
}
static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package )
{
static const WCHAR table[] = {

View File

@ -386,9 +386,6 @@ static UINT ControlEvent_ReinstallMode(MSIPACKAGE *package, LPCWSTR argument,
static UINT ControlEvent_ValidateProductID(MSIPACKAGE *package, LPCWSTR argument,
msi_dialog *dialog)
{
static const WCHAR szProductID[] = {'P','r','o','d','u','c','t','I','D',0};
static const WCHAR szPIDTemplate[] = {'P','I','D','T','e','m','p','l','a','t','e',0};
static const WCHAR szPIDKEY[] = {'P','I','D','K','E','Y',0};
LPWSTR key, template;
UINT ret = ERROR_SUCCESS;

View File

@ -1072,6 +1072,9 @@ static const WCHAR szFindRelatedProducts[] = {'F','i','n','d','R','e','l','a','t
static const WCHAR szAllUsers[] = {'A','L','L','U','S','E','R','S',0};
static const WCHAR szCustomActionData[] = {'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0};
static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
static const WCHAR szProductID[] = {'P','r','o','d','u','c','t','I','D',0};
static const WCHAR szPIDTemplate[] = {'P','I','D','T','e','m','p','l','a','t','e',0};
static const WCHAR szPIDKEY[] = {'P','I','D','K','E','Y',0};
/* memory allocation macro functions */
static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);

View File

@ -1220,6 +1220,46 @@ static const CHAR font_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
"PublishProduct\t\t6400\n"
"InstallFinalize\t\t6600";
static const CHAR vp_property_dat[] = "Property\tValue\n"
"s72\tl0\n"
"Property\tProperty\n"
"HASUIRUN\t0\n"
"INSTALLLEVEL\t3\n"
"InstallMode\tTypical\n"
"Manufacturer\tWine\n"
"PIDTemplate\t###-#######\n"
"ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
"ProductLanguage\t1033\n"
"ProductName\tMSITEST\n"
"ProductVersion\t1.1.1\n"
"UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n";
static const CHAR vp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
"s72\ti2\tS64\tS0\tS255\n"
"CustomAction\tAction\n"
"SetProductID1\t51\tProductID\t1\t\n"
"SetProductID2\t51\tProductID\t2\t\n"
"TestProductID1\t19\t\t\tHalts installation\n"
"TestProductID2\t19\t\t\tHalts installation\n";
static const CHAR vp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
"s72\tS255\tI2\n"
"InstallExecuteSequence\tAction\n"
"LaunchConditions\t\t100\n"
"CostInitialize\t\t800\n"
"FileCost\t\t900\n"
"CostFinalize\t\t1000\n"
"InstallValidate\t\t1400\n"
"InstallInitialize\t\t1500\n"
"SetProductID1\tSET_PRODUCT_ID=1\t3000\n"
"SetProductID2\tSET_PRODUCT_ID=2\t3100\n"
"ValidateProductID\t\t3200\n"
"InstallExecute\t\t3300\n"
"TestProductID1\tProductID=1\t3400\n"
"TestProductID2\tProductID=\"123-1234567\"\t3500\n"
"InstallFiles\t\t4000\n"
"InstallFinalize\t\t6000\n";
typedef struct _msi_table
{
const CHAR *filename;
@ -2003,6 +2043,19 @@ static const msi_table font_tables[] =
ADD_TABLE(property)
};
static const msi_table vp_tables[] =
{
ADD_TABLE(component),
ADD_TABLE(directory),
ADD_TABLE(feature),
ADD_TABLE(feature_comp),
ADD_TABLE(file),
ADD_TABLE(vp_custom_action),
ADD_TABLE(vp_install_exec_seq),
ADD_TABLE(media),
ADD_TABLE(vp_property)
};
/* cabinet definitions */
/* make the max size large so there is only one cab file */
@ -7811,6 +7864,43 @@ static void test_register_font(void)
delete_test_files();
}
static void test_validate_product_id(void)
{
UINT r;
create_test_files();
create_database(msifile, vp_tables, sizeof(vp_tables) / sizeof(msi_table));
MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
r = MsiInstallProductA(msifile, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=1");
ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=2");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
r = MsiInstallProductA(msifile, "PIDKEY=123-1234567");
ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
ok(delete_pf("msitest", FALSE), "Directory not created\n");
delete_test_files();
}
START_TEST(install)
{
DWORD len;
@ -7908,6 +7998,7 @@ START_TEST(install)
test_delete_services();
test_self_registration();
test_register_font();
test_validate_product_id();
DeleteFileA(log_file);