VirtualBox

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

Last change on this file since 78493 was 76562, checked in by vboxsync, 6 years ago

Main: Use MAIN_INCLUDED_ and MAIN_INCLUDED_SRC_ as header guard prefixes with scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: UnattendedScript.h 76562 2019-01-01 03:22:50Z vboxsync $ */
2/** @file
3 * Classes for reading/parsing/saving scripts for unattended installation.
4 */
5
6/*
7 * Copyright (C) 2006-2019 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#if 0 /* convert when we fix SUSE */
100/**
101 * SUSE unattended XML file editor.
102 */
103class UnattendedSUSEXMLScript : public UnattendedXMLScript
104{
105public:
106 UnattendedSUSEXMLScript(VirtualBoxBase *pSetError, const char *pszDefaultFilename = "autoinst.xml")
107 : UnattendedXMLScript(pSetError, pszDefaultFilename) {}
108 ~UnattendedSUSEXMLScript() {}
109
110 HRESULT parse();
111
112protected:
113 HRESULT setFieldInElement(xml::ElementNode *pElement, const DataId enmDataId, const Utf8Str &rStrValue);
114
115private:
116 //////////////////New functions//////////////////////////////
117 /** @throws std::bad_alloc */
118 HRESULT LoopThruSections(const xml::ElementNode *pelmRoot);
119 /** @throws std::bad_alloc */
120 HRESULT HandleUserAccountsSection(const xml::ElementNode *pelmSection);
121 /** @throws std::bad_alloc */
122 Utf8Str createProbableValue(const DataId enmDataId, const xml::ElementNode *pCurElem);
123 /** @throws std::bad_alloc */
124 Utf8Str createProbableUserHomeDir(const xml::ElementNode *pCurElem);
125 //////////////////New functions//////////////////////////////
126};
127#endif
128
129
130#endif /* !MAIN_INCLUDED_UnattendedScript_h */
131
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette