| 1 | #pragma once |
| 2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 3 | |
| 4 | |
| 5 | #include "wcautil.h" |
| 6 | |
| 7 | // Enumerations |
| 8 | typedef enum eWrapQueryAction |
| 9 | { |
| 10 | wqaTableBegin = 1, |
| 11 | wqaTableFinish, |
| 12 | wqaRowBegin, |
| 13 | wqaRowFinish |
| 14 | } eWrapQueryAction; |
| 15 | |
| 16 | typedef enum eColumnDataType |
| 17 | { |
| 18 | cdtString = 1, |
| 19 | cdtInt, |
| 20 | cdtStream, |
| 21 | cdtUnknown |
| 22 | } eColumnDataType; |
| 23 | |
| 24 | typedef enum eFormatMaskColumn |
| 25 | { |
| 26 | efmcColumn1 = 1, |
| 27 | efmcColumn2 = 1 << 1, |
| 28 | efmcColumn3 = 1 << 2, |
| 29 | efmcColumn4 = 1 << 3, |
| 30 | efmcColumn5 = 1 << 4, |
| 31 | efmcColumn6 = 1 << 5, |
| 32 | efmcColumn7 = 1 << 6, |
| 33 | efmcColumn8 = 1 << 7, |
| 34 | efmcColumn9 = 1 << 8, |
| 35 | efmcColumn10 = 1 << 9, |
| 36 | efmcColumn11 = 1 << 10, |
| 37 | efmcColumn12 = 1 << 11, |
| 38 | efmcColumn13 = 1 << 12, |
| 39 | efmcColumn14 = 1 << 13, |
| 40 | efmcColumn15 = 1 << 14, |
| 41 | efmcColumn16 = 1 << 15, |
| 42 | efmcColumn17 = 1 << 16, |
| 43 | efmcColumn18 = 1 << 17, |
| 44 | efmcColumn19 = 1 << 18, |
| 45 | efmcColumn20 = 1 << 19, |
| 46 | efmcColumn21 = 1 << 20, |
| 47 | efmcColumn22 = 1 << 21, |
| 48 | efmcColumn23 = 1 << 22, |
| 49 | efmcColumn24 = 1 << 23, |
| 50 | efmcColumn25 = 1 << 24, |
| 51 | efmcColumn26 = 1 << 25, |
| 52 | efmcColumn27 = 1 << 26, |
| 53 | efmcColumn28 = 1 << 27, |
| 54 | efmcColumn29 = 1 << 28, |
| 55 | efmcColumn30 = 1 << 29, |
| 56 | efmcColumn31 = 1 << 30, |
| 57 | efmcColumn32 = 1 << 31, |
| 58 | } eFormatMaskColumn; |
| 59 | |
| 60 | // Keeps track of the query instance for the reading CA (deferred CA) |
| 61 | typedef struct WCA_WRAPQUERY_STRUCT |
| 62 | { |
| 63 | // These are used to size our dynamic arrays below |
| 64 | DWORD dwColumns, dwRows, dwNextIndex; |
| 65 | |
| 66 | // Dynamic arrays of column schema information |
| 67 | eColumnDataType *pcdtColumnType; |
| 68 | LPWSTR *ppwzColumnNames; |
| 69 | |
| 70 | // Dynamic array of raw record data |
| 71 | MSIHANDLE *phRecords; |
| 72 | } *WCA_WRAPQUERY_HANDLE; |
| 73 | |
| 74 | // Wrap a query |
| 75 | // Setting the pfFormatMask enables control over which fields will be formatted, and which will be left unchanged |
| 76 | // Setting dwComponentColumn to something other than 0xFFFFFFFF tells WcaWrapQuery to add two additional columns to the right side of the table |
| 77 | // - ISInstalled and ISAction - which map to the ComponentState of the component (the component is found in the column specified) |
| 78 | // Note that if a component is NULL, the component state columns will also be left null, and it will be up to the deferred CA to fail or ignore the case appropriately |
| 79 | // Setting dwDirectoryColumn to something other than 0xFFFFFFFF tells WcaWrapQuery to add two more additional columns to the right side of the table |
| 80 | // - SourcePath and TargetPath - which map to the Directory's Source and Target Path (the directory is found in the column specified) |
| 81 | // Note that if a directory is NULL, the directory source/target path columns will also be left null, and it will be up to the deferred CA to fail or ignore the case appropriately |
| 82 | HRESULT WIXAPI WcaWrapQuery( |
| 83 | __in_z LPCWSTR pwzQuery, |
| 84 | __inout LPWSTR * ppwzCustomActionData, |
| 85 | __in_opt DWORD dwFormatMask, |
| 86 | __in_opt DWORD dwComponentColumn, |
| 87 | __in_opt DWORD dwDirectoryColumn |
| 88 | ); |
| 89 | // This wraps an empty table query into the custom action data - this is a way to indicate to the deferred custom action that a necessary table doesn't exist, or its query returned no results |
| 90 | HRESULT WIXAPI WcaWrapEmptyQuery( |
| 91 | __inout LPWSTR * ppwzCustomActionData |
| 92 | ); |
| 93 | |
| 94 | // Open a new unwrap query operation, with data from the ppwzCustomActionData string |
| 95 | HRESULT WIXAPI WcaBeginUnwrapQuery( |
| 96 | __out WCA_WRAPQUERY_HANDLE * phWrapQuery, |
| 97 | __inout LPWSTR * ppwzCustomActionData |
| 98 | ); |
| 99 | |
| 100 | // Get the number of records in a query being unwrapped |
| 101 | DWORD WIXAPI WcaGetQueryRecords( |
| 102 | __in const WCA_WRAPQUERY_HANDLE hWrapQuery |
| 103 | ); |
| 104 | |
| 105 | // This function resets a query back to its first row, so that the next fetch returns the first record |
| 106 | void WIXAPI WcaFetchWrappedReset( |
| 107 | __in WCA_WRAPQUERY_HANDLE hWrapQuery |
| 108 | ); |
| 109 | // Fetch the next record in this query |
| 110 | // NOTE: the MSIHANDLE returned by this function should not be released, as it is the same handle used by the query object to maintain the item. |
| 111 | // so, don't use this function with PMSIHANDLE objects! |
| 112 | HRESULT WIXAPI WcaFetchWrappedRecord( |
| 113 | __in WCA_WRAPQUERY_HANDLE hWrapQuery, |
| 114 | __out MSIHANDLE* phRec |
| 115 | ); |
| 116 | |
| 117 | // Fetch the next record in the query where the string value in column dwComparisonColumn equals the value pwzExpectedValue |
| 118 | // NOTE: the MSIHANDLE returned by this function should not be released, as it is the same handle used by the query object to maintain the item. |
| 119 | // so, don't use this function with PMSIHANDLE objects! |
| 120 | HRESULT WIXAPI WcaFetchWrappedRecordWhereString( |
| 121 | __in WCA_WRAPQUERY_HANDLE hWrapQuery, |
| 122 | __in DWORD dwComparisonColumn, |
| 123 | __in_z LPCWSTR pwzExpectedValue, |
| 124 | __out MSIHANDLE* phRec |
| 125 | ); |
| 126 | |
| 127 | // Release a query ID (frees memory, and frees the ID for a new query) |
| 128 | void WIXAPI WcaFinishUnwrapQuery( |
| 129 | __in_opt WCA_WRAPQUERY_HANDLE hWrapQuery |
| 130 | ); |