1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_UNOTOOLS_BOOTSTRAP_HXX
21 #define INCLUDED_UNOTOOLS_BOOTSTRAP_HXX
23 #include <unotools/unotoolsdllapi.h>
24 #include <rtl/ustring.hxx>
28 /** provides configuration information needed for application startup.
29 <p>This class handles the startup information for the office application.
30 It encapsulates knowledge of how to retriev such information and how
31 to diagnose failures to retriev required data.
34 class UNOTOOLS_DLLPUBLIC Bootstrap
36 // the static interface
37 public: // some common information items
39 /// retrieve the product key; defaults to executable name (without extension)
40 static OUString
getProductKey();
42 /// retrieve the product key; uses the given default, if not found
43 static OUString
getProductKey(OUString
const& _sDefault
);
45 /// retrieve the BUILDID information item; uses the given default, if not found
46 static OUString
getBuildIdData(OUString
const& _sDefault
);
48 /// retrieve the BuildVersion information item; uses the given default, if not found
49 static OUString
getBuildVersion(OUString
const& _sDefault
);
51 /// reload cached data
52 static void reloadData();
54 public: // retrieve path information about the installation location
57 PATH_EXISTS
, // Success: Found a path to an existing file or directory
58 PATH_VALID
, // Found a valid path, but the file or directory does not exist
59 DATA_INVALID
, // Retrieved a string for this path, that is not a valid file url or system path
60 DATA_MISSING
, // Could not retrieve any data for this path
61 DATA_UNKNOWN
// No attempt to retrieve data for this path was made
64 /// get a file URL to the common base installation [${insturl}]
65 static PathStatus
locateBaseInstallation(OUString
& _rURL
);
67 /// get a file URL to the user installation [${userurl}]
68 static PathStatus
locateUserInstallation(OUString
& _rURL
);
70 /// get a file URL to the user data directory [default is ${userurl}/user]
71 static PathStatus
locateUserData(OUString
& _rURL
);
73 // the next two items are mainly supported for diagnostic purposes. both items may be unused
74 /// get a file URL to the bootstrap INI file used [e.g. ${insturl}/program/bootraprc]
75 static PathStatus
locateBootstrapFile(OUString
& _rURL
);
76 /// get a file URL to the version locator INI file used [e.g. ${SYSUSERCONFIG}/sversion.ini]
77 static PathStatus
locateVersionFile(OUString
& _rURL
);
79 public: // evaluate the validity of the installation
80 /// high-level status of bootstrap success
83 DATA_OK
, /// user-dir and share-dir do exist, product key found or can be defaulted to exe-name
84 MISSING_USER_INSTALL
, /// ${userurl} does not exist; or version-file cannot be found or is invalid
85 INVALID_USER_INSTALL
, /// can locate ${userurl}, but user-dir is missing
86 INVALID_BASE_INSTALL
/// other failure: e.g. cannot locate share-dir; bootstraprc missing or invalid; no product key
89 /// error code for detailed diagnostics of bootstrap failures
92 NO_FAILURE
, /// bootstrap was successful
93 MISSING_INSTALL_DIRECTORY
, /// the shared installation directory could not be located
94 MISSING_BOOTSTRAP_FILE
, /// the bootstrap INI file could not be found or read
95 MISSING_BOOTSTRAP_FILE_ENTRY
, /// the bootstrap INI is missing a required entry
96 INVALID_BOOTSTRAP_FILE_ENTRY
, /// the bootstrap INI contains invalid data
97 MISSING_VERSION_FILE
, /// the version locator INI file could not be found or read
98 MISSING_VERSION_FILE_ENTRY
, /// the version locator INI has no entry for this version
99 INVALID_VERSION_FILE_ENTRY
, /// the version locator INI entry is not a valid directory URL
100 MISSING_USER_DIRECTORY
, /// the user installation directory does not exist
101 INVALID_BOOTSTRAP_DATA
/// some bootstrap data was invalid in unexpected ways
104 /** Evaluates the status of the installation and returns a diagnostic
105 message and error code corresponding to this status
107 static Status
checkBootstrapStatus(OUString
& _rDiagnosticMessage
, FailureCode
& _rErrCode
);
110 // singleton impl-class
112 static const Impl
& data(); // the data related to the bootstrap.ini file
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */