aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Iis/ca/scaiis7.cpp
blob: aaf307d732a088b819abaafcccb5921d1f106516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// 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.

#include "precomp.h"

#define COST_IIS_WRITEKEY 10

HRESULT ScaIIS7ConfigTransaction(LPCWSTR wzBackup)
{
    HRESULT hr = S_OK;

    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"StartIIS7ConfigTransaction"), wzBackup, COST_IIS_TRANSACTIONS);
    ExitOnFailure(hr, "Failed to schedule StartIIS7ConfigTransaction");

    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackIIS7ConfigTransaction"), wzBackup, 0);   // rollback cost is irrelevant
    ExitOnFailure(hr, "Failed to schedule RollbackIIS7ConfigTransaction");

    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CommitIIS7ConfigTransaction"), wzBackup, 0);  // commit is free
    ExitOnFailure(hr, "Failed to schedule StartIIS7ConfigTransaction");

LExit:
    return hr;
}

HRESULT ScaWriteConfigString(const LPCWSTR wzValue)
{
    HRESULT hr = S_OK;
    WCHAR* pwzCustomActionData = NULL;

    hr = WcaWriteStringToCaData(wzValue, &pwzCustomActionData);
    ExitOnFailure(hr, "Failed to add metabase delete key directive to CustomActionData");

    hr = ScaAddToIisConfiguration(pwzCustomActionData, COST_IIS_WRITEKEY);
    ExitOnFailure(hr, "Failed to add ScaWriteMetabaseValue action data: %ls, cost: %d", pwzCustomActionData, COST_IIS_WRITEKEY);

LExit:
    ReleaseStr(pwzCustomActionData);

    return hr;
}

HRESULT ScaWriteConfigInteger(DWORD dwValue)
{
    HRESULT hr = S_OK;
    WCHAR* pwzCustomActionData = NULL;

    hr = WcaWriteIntegerToCaData(dwValue, &pwzCustomActionData);
    ExitOnFailure(hr, "Failed to add metabase delete key directive to CustomActionData");

    hr = ScaAddToIisConfiguration(pwzCustomActionData, COST_IIS_WRITEKEY);
    ExitOnFailure(hr, "Failed to add ScaWriteMetabaseValue action data: %ls, cost: %d", pwzCustomActionData, COST_IIS_WRITEKEY);

LExit:
    ReleaseStr(pwzCustomActionData);

    return hr;
}

HRESULT ScaWriteConfigID(IIS_CONFIG_ACTION emID)
{
    HRESULT hr = S_OK;
    WCHAR* pwzCustomActionData = NULL;

    hr = WcaWriteIntegerToCaData(emID, &pwzCustomActionData);
    ExitOnFailure(hr, "Failed to add metabase delete key directive to CustomActionData");

    hr = ScaAddToIisConfiguration(pwzCustomActionData, COST_IIS_WRITEKEY);
    ExitOnFailure(hr, "Failed to add ScaWriteMetabaseValue action data: %ls, cost: %d", pwzCustomActionData, COST_IIS_WRITEKEY);

LExit:
    ReleaseStr(pwzCustomActionData);

    return hr;
}