|
1 | | -// Berkeley Open Infrastructure for Network Computing |
2 | | -// http://boinc.berkeley.edu |
3 | | -// Copyright (C) 2005 University of California |
| 1 | +// This file is part of BOINC. |
| 2 | +// https://boinc.berkeley.edu |
| 3 | +// Copyright (C) 2026 University of California |
4 | 4 | // |
5 | | -// This is free software; you can redistribute it and/or |
6 | | -// modify it under the terms of the GNU Lesser General Public |
7 | | -// License as published by the Free Software Foundation; |
8 | | -// either version 2.1 of the License, or (at your option) any later version. |
| 5 | +// BOINC is free software; you can redistribute it and/or modify it |
| 6 | +// under the terms of the GNU Lesser General Public License |
| 7 | +// as published by the Free Software Foundation, |
| 8 | +// either version 3 of the License, or (at your option) any later version. |
9 | 9 | // |
10 | | -// This software is distributed in the hope that it will be useful, |
| 10 | +// BOINC is distributed in the hope that it will be useful, |
11 | 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13 | 13 | // See the GNU Lesser General Public License for more details. |
14 | 14 | // |
15 | | -// To view the GNU Lesser General Public License visit |
16 | | -// http://www.gnu.org/copyleft/lesser.html |
17 | | -// or write to the Free Software Foundation, Inc., |
18 | | -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | -// |
| 15 | +// You should have received a copy of the GNU Lesser General Public License |
| 16 | +// along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
20 | 17 |
|
21 | 18 | #include "stdafx.h" |
22 | 19 | #include "boinccas.h" |
23 | | -#include "CARestoreExecutionState.h" |
24 | | - |
25 | | -#define CUSTOMACTION_NAME _T("CARestoreExecutionState") |
26 | | -#define CUSTOMACTION_PROGRESSTITLE _T("") |
27 | | - |
28 | | - |
29 | | -///////////////////////////////////////////////////////////////////// |
30 | | -// |
31 | | -// Function: |
32 | | -// |
33 | | -// Description: |
34 | | -// |
35 | | -///////////////////////////////////////////////////////////////////// |
36 | | -CARestoreExecutionState::CARestoreExecutionState(MSIHANDLE hMSIHandle) : |
37 | | - BOINCCABase(hMSIHandle, CUSTOMACTION_NAME, CUSTOMACTION_PROGRESSTITLE) |
38 | | -{} |
39 | | - |
40 | 20 |
|
41 | | -///////////////////////////////////////////////////////////////////// |
42 | | -// |
43 | | -// Function: |
44 | | -// |
45 | | -// Description: |
46 | | -// |
47 | | -///////////////////////////////////////////////////////////////////// |
48 | | -CARestoreExecutionState::~CARestoreExecutionState() |
49 | | -{ |
50 | | - BOINCCABase::~BOINCCABase(); |
| 21 | +class CARestoreExecutionState : public BOINCCABase { |
| 22 | +public: |
| 23 | + virtual ~CARestoreExecutionState() = default; |
| 24 | + explicit CARestoreExecutionState(MSIHANDLE hMSIHandle) : |
| 25 | + BOINCCABase(hMSIHandle, _T("CARestoreExecutionState"), |
| 26 | + _T("Restore previous execution state")) { |
| 27 | + } |
| 28 | + |
| 29 | + UINT OnExecution() override final { |
| 30 | + tstring strLaunchProgram; |
| 31 | + GetRegistryValue(_T("LAUNCHPROGRAM"), |
| 32 | + strLaunchProgram); |
| 33 | + SetProperty(_T("LAUNCHPROGRAM"), |
| 34 | + strLaunchProgram); |
| 35 | + |
| 36 | + tstring strReturnRebootRequested; |
| 37 | + GetRegistryValue(_T("RETURN_REBOOTREQUESTED"), |
| 38 | + strReturnRebootRequested); |
| 39 | + SetProperty(_T("RETURN_REBOOTREQUESTED"), |
| 40 | + strReturnRebootRequested); |
| 41 | + |
| 42 | + tstring strReturnValidateInstall; |
| 43 | + GetRegistryValue(_T("RETURN_VALIDATEINSTALL"), |
| 44 | + strReturnValidateInstall); |
| 45 | + SetProperty(_T("RETURN_VALIDATEINSTALL"), |
| 46 | + strReturnValidateInstall); |
| 47 | + |
| 48 | + tstring strBOINCMasterAccountUsername; |
| 49 | + GetRegistryValue(_T("RETURN_BOINC_MASTER_USERNAME"), |
| 50 | + strBOINCMasterAccountUsername); |
| 51 | + SetProperty(_T("BOINC_MASTER_USERNAME"), |
| 52 | + strBOINCMasterAccountUsername); |
| 53 | + |
| 54 | + tstring strBOINCProjectAccountUsername; |
| 55 | + GetRegistryValue(_T("RETURN_BOINC_PROJECT_USERNAME"), |
| 56 | + strBOINCProjectAccountUsername); |
| 57 | + SetProperty(_T("BOINC_PROJECT_USERNAME"), |
| 58 | + strBOINCProjectAccountUsername); |
| 59 | + |
| 60 | + return ERROR_SUCCESS; |
| 61 | + } |
| 62 | +}; |
| 63 | + |
| 64 | +UINT __stdcall RestoreExecutionState(MSIHANDLE hInstall) { |
| 65 | + return CARestoreExecutionState(hInstall).Execute(); |
51 | 66 | } |
52 | | - |
53 | | - |
54 | | -///////////////////////////////////////////////////////////////////// |
55 | | -// |
56 | | -// Function: |
57 | | -// |
58 | | -// Description: |
59 | | -// |
60 | | -///////////////////////////////////////////////////////////////////// |
61 | | -UINT CARestoreExecutionState::OnExecution() |
62 | | -{ |
63 | | - tstring strLaunchProgram; |
64 | | - tstring strReturnRebootRequested; |
65 | | - tstring strReturnValidateInstall; |
66 | | - tstring strRebootPrompt; |
67 | | - tstring strBOINCMasterAccountUsername; |
68 | | - tstring strBOINCProjectAccountUsername; |
69 | | - |
70 | | - GetRegistryValue( _T("LAUNCHPROGRAM"), strLaunchProgram ); |
71 | | - GetRegistryValue( _T("REBOOTPROMPT"), strRebootPrompt ); |
72 | | - GetRegistryValue( _T("RETURN_REBOOTREQUESTED"), strReturnRebootRequested ); |
73 | | - GetRegistryValue( _T("RETURN_VALIDATEINSTALL"), strReturnValidateInstall ); |
74 | | - GetRegistryValue( _T("RETURN_BOINC_MASTER_USERNAME"), strBOINCMasterAccountUsername ); |
75 | | - GetRegistryValue( _T("RETURN_BOINC_PROJECT_USERNAME"), strBOINCProjectAccountUsername ); |
76 | | - |
77 | | - SetProperty( _T("LAUNCHPROGRAM"), strLaunchProgram ); |
78 | | - SetProperty( _T("REBOOTPROMPT"), strRebootPrompt ); |
79 | | - SetProperty( _T("RETURN_REBOOTREQUESTED"), strReturnRebootRequested ); |
80 | | - SetProperty( _T("RETURN_VALIDATEINSTALL"), strReturnValidateInstall ); |
81 | | - SetProperty( _T("BOINC_MASTER_USERNAME"), strBOINCMasterAccountUsername ); |
82 | | - SetProperty( _T("BOINC_PROJECT_USERNAME"), strBOINCProjectAccountUsername ); |
83 | | - |
84 | | - return ERROR_SUCCESS; |
85 | | -} |
86 | | - |
87 | | - |
88 | | -///////////////////////////////////////////////////////////////////// |
89 | | -// |
90 | | -// Function: RestoreExecutionState |
91 | | -// |
92 | | -// Description: |
93 | | -// |
94 | | -///////////////////////////////////////////////////////////////////// |
95 | | -UINT __stdcall RestoreExecutionState(MSIHANDLE hInstall) |
96 | | -{ |
97 | | - UINT uiReturnValue = 0; |
98 | | - |
99 | | - CARestoreExecutionState* pCA = new CARestoreExecutionState(hInstall); |
100 | | - uiReturnValue = pCA->Execute(); |
101 | | - delete pCA; |
102 | | - |
103 | | - return uiReturnValue; |
104 | | -} |
105 | | - |
0 commit comments