VirtualBox

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

Last change on this file since 92154 was 90828, checked in by vboxsync, 3 years ago

Main: bugref:1909: Added API localization

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: UnattendedScript.h 90828 2021-08-24 09:44:46Z 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 DECLARE_TRANSLATE_METHODS(UnattendedScriptTemplate)
46
47 UnattendedScriptTemplate(Unattended *pUnattended, const char *pszDefaultTemplateFilename, const char *pszDefaultFilename);
48 virtual ~UnattendedScriptTemplate() {}
49
50 HRESULT parse() { return S_OK; }
51 HRESULT saveToString(Utf8Str &rStrDst);
52
53protected:
54 /**
55 * Gets the replacement value for the given placeholder.
56 *
57 * @returns COM status code.
58 * @param pachPlaceholder The placholder string. Not zero terminated.
59 * @param cchPlaceholder The length of the placeholder.
60 * @param fOutputting Indicates whether we actually need the correct value
61 * or is just syntax checking excluded template parts.
62 * @param rValue Where to return the value.
63 */
64 HRESULT getReplacement(const char *pachPlaceholder, size_t cchPlaceholder, bool fOutputting, RTCString &rValue);
65
66 /**
67 * Overridable worker for getReplacement.
68 *
69 * @returns COM status code.
70 * @param pachPlaceholder The placholder string. Not zero terminated.
71 * @param cchPlaceholder The length of the placeholder.
72 * @param cchFullPlaceholder The full placeholder length, including suffixes
73 * indicating how it should be escaped (for error
74 * messages).
75 * @param fOutputting Indicates whether we actually need the correct
76 * value or is just syntax checking excluded
77 * template parts. Intended for voiding triggering
78 * sanity checks regarding which replacements
79 * should be used and not (e.g. no Guest Additions
80 * path when installing GAs aren't enabled).
81 * @param rValue Where to return the value.
82 * @throws std::bad_alloc
83 */
84 virtual HRESULT getUnescapedReplacement(const char *pachPlaceholder, size_t cchPlaceholder,
85 size_t cchFullPlaceholder, bool fOutputting, RTCString &rValue);
86
87
88 /**
89 * Get the result of a conditional.
90 *
91 * @returns COM status code.
92 * @param pachPlaceholder The placholder string. Not zero terminated.
93 * @param cchPlaceholder The length of the placeholder.
94 * @param pfOutputting Where to return the result of the conditional.
95 * This holds the current outputting state on input
96 * in case someone want to sanity check anything.
97 */
98 virtual HRESULT getConditional(const char *pachPlaceholder, size_t cchPlaceholder, bool *pfOutputting);
99
100};
101
102#if 0 /* convert when we fix SUSE */
103/**
104 * SUSE unattended XML file editor.
105 */
106class UnattendedSUSEXMLScript : public UnattendedXMLScript
107{
108public:
109 DECLARE_TRANSLATE_METHODS(UnattendedSUSEXMLScript)
110
111 UnattendedSUSEXMLScript(VirtualBoxBase *pSetError, const char *pszDefaultFilename = "autoinst.xml")
112 : UnattendedXMLScript(pSetError, pszDefaultFilename) {}
113 ~UnattendedSUSEXMLScript() {}
114
115 HRESULT parse();
116
117protected:
118 HRESULT setFieldInElement(xml::ElementNode *pElement, const DataId enmDataId, const Utf8Str &rStrValue);
119
120private:
121 //////////////////New functions//////////////////////////////
122 /** @throws std::bad_alloc */
123 HRESULT LoopThruSections(const xml::ElementNode *pelmRoot);
124 /** @throws std::bad_alloc */
125 HRESULT HandleUserAccountsSection(const xml::ElementNode *pelmSection);
126 /** @throws std::bad_alloc */
127 Utf8Str createProbableValue(const DataId enmDataId, const xml::ElementNode *pCurElem);
128 /** @throws std::bad_alloc */
129 Utf8Str createProbableUserHomeDir(const xml::ElementNode *pCurElem);
130 //////////////////New functions//////////////////////////////
131};
132#endif
133
134
135#endif /* !MAIN_INCLUDED_UnattendedScript_h */
136
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use