aboutsummaryrefslogtreecommitdiff
path: root/src/engine/search.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/search.cpp')
-rw-r--r--src/engine/search.cpp71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/engine/search.cpp b/src/engine/search.cpp
index 763286fd..16f8e459 100644
--- a/src/engine/search.cpp
+++ b/src/engine/search.cpp
@@ -48,6 +48,10 @@ static HRESULT MsiFeatureSearch(
48static HRESULT PerformExtensionSearch( 48static HRESULT PerformExtensionSearch(
49 __in BURN_SEARCH* pSearch 49 __in BURN_SEARCH* pSearch
50 ); 50 );
51static HRESULT PerformSetVariable(
52 __in BURN_SEARCH* pSearch,
53 __in BURN_VARIABLES* pVariables
54);
51 55
52 56
53// function definitions 57// function definitions
@@ -64,9 +68,10 @@ extern "C" HRESULT SearchesParseFromXml(
64 DWORD cNodes = 0; 68 DWORD cNodes = 0;
65 BSTR bstrNodeName = NULL; 69 BSTR bstrNodeName = NULL;
66 LPWSTR scz = NULL; 70 LPWSTR scz = NULL;
71 BURN_VARIANT_TYPE valueType = BURN_VARIANT_TYPE_NONE;
67 72
68 // select search nodes 73 // select search nodes
69 hr = XmlSelectNodes(pixnBundle, L"DirectorySearch|FileSearch|RegistrySearch|MsiComponentSearch|MsiProductSearch|MsiFeatureSearch|ExtensionSearch", &pixnNodes); 74 hr = XmlSelectNodes(pixnBundle, L"DirectorySearch|FileSearch|RegistrySearch|MsiComponentSearch|MsiProductSearch|MsiFeatureSearch|ExtensionSearch|SetVariable", &pixnNodes);
70 ExitOnFailure(hr, "Failed to select search nodes."); 75 ExitOnFailure(hr, "Failed to select search nodes.");
71 76
72 // get search node count 77 // get search node count
@@ -388,6 +393,50 @@ extern "C" HRESULT SearchesParseFromXml(
388 hr = BurnExtensionFindById(pBurnExtensions, scz, &pSearch->ExtensionSearch.pExtension); 393 hr = BurnExtensionFindById(pBurnExtensions, scz, &pSearch->ExtensionSearch.pExtension);
389 ExitOnFailure(hr, "Failed to find extension '%ls' for search '%ls'", scz, pSearch->sczKey); 394 ExitOnFailure(hr, "Failed to find extension '%ls' for search '%ls'", scz, pSearch->sczKey);
390 } 395 }
396 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"SetVariable", -1))
397 {
398 pSearch->Type = BURN_SEARCH_TYPE_SET_VARIABLE;
399
400 // @Value
401 hr = XmlGetAttributeEx(pixnNode, L"Value", &scz);
402 if (E_NOTFOUND != hr)
403 {
404 ExitOnFailure(hr, "Failed to get @Value.");
405
406 hr = BVariantSetString(&pSearch->SetVariable.value, scz, 0);
407 ExitOnFailure(hr, "Failed to set variant value.");
408
409 // @Type
410 hr = XmlGetAttributeEx(pixnNode, L"Type", &scz);
411 ExitOnFailure(hr, "Failed to get @Type.");
412
413 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"numeric", -1))
414 {
415 valueType = BURN_VARIANT_TYPE_NUMERIC;
416 }
417 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"string", -1))
418 {
419 valueType = BURN_VARIANT_TYPE_STRING;
420 }
421 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"version", -1))
422 {
423 valueType = BURN_VARIANT_TYPE_VERSION;
424 }
425 else
426 {
427 hr = E_INVALIDARG;
428 ExitOnFailure(hr, "Invalid value for @Type: %ls", scz);
429 }
430 }
431 else
432 {
433 valueType = BURN_VARIANT_TYPE_NONE;
434 }
435
436 // change value variant to correct type
437 hr = BVariantChangeType(&pSearch->SetVariable.value, valueType);
438 ExitOnFailure(hr, "Failed to change variant type.");
439 }
391 else 440 else
392 { 441 {
393 hr = E_UNEXPECTED; 442 hr = E_UNEXPECTED;
@@ -495,6 +544,9 @@ extern "C" HRESULT SearchesExecute(
495 case BURN_SEARCH_TYPE_EXTENSION: 544 case BURN_SEARCH_TYPE_EXTENSION:
496 hr = PerformExtensionSearch(pSearch); 545 hr = PerformExtensionSearch(pSearch);
497 break; 546 break;
547 case BURN_SEARCH_TYPE_SET_VARIABLE:
548 hr = PerformSetVariable(pSearch, pVariables);
549 break;
498 default: 550 default:
499 hr = E_UNEXPECTED; 551 hr = E_UNEXPECTED;
500 } 552 }
@@ -549,6 +601,9 @@ extern "C" void SearchesUninitialize(
549 ReleaseStr(pSearch->MsiFeatureSearch.sczProductCode); 601 ReleaseStr(pSearch->MsiFeatureSearch.sczProductCode);
550 ReleaseStr(pSearch->MsiFeatureSearch.sczFeatureId); 602 ReleaseStr(pSearch->MsiFeatureSearch.sczFeatureId);
551 break; 603 break;
604 case BURN_SEARCH_TYPE_SET_VARIABLE:
605 BVariantUninitialize(&pSearch->SetVariable.value);
606 break;
552 } 607 }
553 } 608 }
554 MemFree(pSearches->rgSearches); 609 MemFree(pSearches->rgSearches);
@@ -1222,3 +1277,17 @@ static HRESULT PerformExtensionSearch(
1222 1277
1223 return hr; 1278 return hr;
1224} 1279}
1280
1281static HRESULT PerformSetVariable(
1282 __in BURN_SEARCH* pSearch,
1283 __in BURN_VARIABLES* pVariables
1284 )
1285{
1286 HRESULT hr = S_OK;
1287
1288 hr = VariableSetVariant(pVariables, pSearch->sczVariable, &pSearch->SetVariable.value);
1289 ExitOnFailure(hr, "Failed to set variable: %ls", pSearch->sczVariable);
1290
1291LExit:
1292 return hr;
1293}