VirtualBox

source: vbox/trunk/src/VBox/Main/include/UnattendedScript.h@ 86506

Last change on this file since 86506 was 86274, checked in by vboxsync, 4 years ago

bugref:9781. New function Unattended::i_getDetectedOSVersion(). New function UnattendedScriptTemplate::getGuestOSConditional(). New placeholders @@VBOX_GUEST_OS_COND_VERSION@@, @@VBOX_INSERT_GUEST_OS_VERSION@@, @@VBOX_INSERT_GUEST_OS_MAJOR_VERSION@@.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/* $Id: UnattendedScript.h 86274 2020-09-24 19:52:56Z vboxsync $ */
2/** @file
3 * Classes for reading/parsing/saving scripts for unattended installation.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef MAIN_INCLUDED_UnattendedScript_h
19#define MAIN_INCLUDED_UnattendedScript_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "TextScript.h"
25
26using namespace xml;
27
28class Unattended;
29
30
31/**
32 * Generic unattended text script template editor.
33 *
34 * This just perform variable replacements, no other editing possible.
35 *
36 * Everything happens during saveToString, parse is a noop.
37 */
38class UnattendedScriptTemplate : public BaseTextScript
39{
40protected:
41 /** Where to get the replacement strings from. */
42 Unattended *mpUnattended;
43
44public:
45 UnattendedScriptTemplate(Unattended *pUnattended, const char *pszDefaultTemplateFilename, const char *pszDefaultFilename);
46 virtual ~UnattendedScriptTemplate() {}
47
48 HRESULT parse() { return S_OK; }
49 HRESULT saveToString(Utf8Str &rStrDst);
50
51protected:
52 /**
53 * Gets the replacement value for the given placeholder.
54 *
55 * @returns COM status code.
56 * @param pachPlaceholder The placholder string. Not zero terminated.
57 * @param cchPlaceholder The length of the placeholder.
58 * @param fOutputting Indicates whether we actually need the correct value
59 * or is just syntax checking excluded template parts.
60 * @param rValue Where to return the value.
61 */
62 HRESULT getReplacement(const char *pachPlaceholder, size_t cchPlaceholder, bool fOutputting, RTCString &rValue);
63
64 /**
65 * Overridable worker for getReplacement.
66 *
67 * @returns COM status code.
68 * @param pachPlaceholder The placholder string. Not zero terminated.
69 * @param cchPlaceholder The length of the placeholder.
70 * @param cchFullPlaceholder The full placeholder length, including suffixes
71 * indicating how it should be escaped (for error
72 * messages).
73 * @param fOutputting Indicates whether we actually need the correct
74 * value or is just syntax checking excluded
75 * template parts. Intended for voiding triggering
76 * sanity checks regarding which replacements
77 * should be used and not (e.g. no Guest Additions
78 * path when installing GAs aren't enabled).
79 * @param rValue Where to return the value.
80 * @throws std::bad_alloc
81 */
82 virtual HRESULT getUnescapedReplacement(const char *pachPlaceholder, size_t cchPlaceholder,
83 size_t cchFullPlaceholder, bool fOutputting, RTCString &rValue);
84
85
86 /**
87 * Get the result of a conditional.
88 *
89 * @returns COM status code.
90 * @param pachPlaceholder The placholder string. Not zero terminated.
91 * @param cchPlaceholder The length of the placeholder.
92 * @param pfOutputting Where to return the result of the conditional.
93 * This holds the current outputting state on input
94 * in case someone want to sanity check anything.
95 */
96 virtual HRESULT getConditional(const char *pachPlaceholder, size_t cchPlaceholder, bool *pfOutputting);
97
98
99 /**
100 * Get the result of a conditional for special version of guest OS.
101 *
102 * @returns COM status code.
103 * @param pachPlaceholder The placholder string. Not zero terminated.
104 * @param cchPlaceholder The length of the placeholder.
105 * @param cchContent The length of placeholder content.
106 * @param pcchCorrect The length of part which must be excluded from the final content of
107 * the placeholder.
108 * @param pfOutputting Where to return the result of the conditional.
109 * This holds the current outputting state on input
110 * in case someone want to sanity check anything.
111 */
112 virtual HRESULT getGuestOSConditional(const char *pachPlaceholder,
113 size_t cchPlaceholder,
114 size_t cchContent,
115 size_t *pcchCorrect,
116 bool *pfOutputting);
117};
118
119#if 0 /* convert when we fix SUSE */
120/**
121 * SUSE unattended XML file editor.
122 */
123class UnattendedSUSEXMLScript : public UnattendedXMLScript
124{
125public:
126 UnattendedSUSEXMLScript(VirtualBoxBase *pSetError, const char *pszDefaultFilename = "autoinst.xml")
127 : UnattendedXMLScript(pSetError, pszDefaultFilename) {}
128 ~UnattendedSUSEXMLScript() {}
129
130 HRESULT parse();
131
132protected:
133 HRESULT setFieldInElement(xml::ElementNode *pElement, const DataId enmDataId, const Utf8Str &rStrValue);
134
135private:
136 //////////////////New functions//////////////////////////////
137 /** @throws std::bad_alloc */
138 HRESULT LoopThruSections(const xml::ElementNode *pelmRoot);
139 /** @throws std::bad_alloc */
140 HRESULT HandleUserAccountsSection(const xml::ElementNode *pelmSection);
141 /** @throws std::bad_alloc */
142 Utf8Str createProbableValue(const DataId enmDataId, const xml::ElementNode *pCurElem);
143 /** @throws std::bad_alloc */
144 Utf8Str createProbableUserHomeDir(const xml::ElementNode *pCurElem);
145 //////////////////New functions//////////////////////////////
146};
147#endif
148
149
150#endif /* !MAIN_INCLUDED_UnattendedScript_h */
151
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use