Bump version to 21.06.18.1
[LibreOffice.git] / include / unotools / bootstrap.hxx
blob3f87741408c4375675129d2a5e86774b57001b01
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
26 namespace utl
28 /** provides configuration information needed for application startup.
30 This class handles the startup information for the office application.
31 It encapsulates knowledge of how to retrieve such information and how
32 to diagnose failures to retrieve required data.
35 class UNOTOOLS_DLLPUBLIC Bootstrap
37 // the static interface
38 public: // some common information items
40 /// retrieve the product key; defaults to executable name (without extension)
41 static OUString getProductKey();
43 /// retrieve the product key; uses the given default, if not found
44 static OUString getProductKey(OUString const& _sDefault);
46 /// retrieve the BUILDID information item; uses the given default, if not found
47 static OUString getBuildIdData(OUString const& _sDefault);
49 /// reload cached data
50 static void reloadData();
52 public: // retrieve path information about the installation location
53 enum PathStatus
55 PATH_EXISTS, // Success: Found a path to an existing file or directory
56 PATH_VALID, // Found a valid path, but the file or directory does not exist
57 DATA_INVALID, // Retrieved a string for this path, that is not a valid file url or system path
58 DATA_MISSING, // Could not retrieve any data for this path
59 DATA_UNKNOWN // No attempt to retrieve data for this path was made
62 /// get a file URL to the common base installation [${insturl}]
63 static PathStatus locateBaseInstallation(OUString& _rURL);
65 /// get a file URL to the user installation [${userurl}]
66 static PathStatus locateUserInstallation(OUString& _rURL);
68 /// get a file URL to the user data directory [default is ${userurl}/user]
69 static PathStatus locateUserData(OUString& _rURL);
71 // the next two items are mainly supported for diagnostic purposes. both items may be unused
72 /// get a file URL to the bootstrap INI file used [e.g. ${insturl}/program/bootraprc]
73 static PathStatus locateBootstrapFile(OUString& _rURL);
74 /// get a file URL to the version locator INI file used [e.g. ${SYSUSERCONFIG}/sversion.ini]
75 static PathStatus locateVersionFile(OUString& _rURL);
77 public: // evaluate the validity of the installation
78 /// high-level status of bootstrap success
79 enum Status
81 DATA_OK, /// user-dir and share-dir do exist, product key found or can be defaulted to exe-name
82 MISSING_USER_INSTALL, /// ${userurl} does not exist; or version-file cannot be found or is invalid
83 INVALID_USER_INSTALL, /// can locate ${userurl}, but user-dir is missing
84 INVALID_BASE_INSTALL /// other failure: e.g. cannot locate share-dir; bootstraprc missing or invalid; no product key
87 /// error code for detailed diagnostics of bootstrap failures
88 enum FailureCode
90 NO_FAILURE, /// bootstrap was successful
91 MISSING_INSTALL_DIRECTORY, /// the shared installation directory could not be located
92 MISSING_BOOTSTRAP_FILE, /// the bootstrap INI file could not be found or read
93 MISSING_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI is missing a required entry
94 INVALID_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI contains invalid data
95 MISSING_VERSION_FILE, /// the version locator INI file could not be found or read
96 MISSING_VERSION_FILE_ENTRY, /// the version locator INI has no entry for this version
97 INVALID_VERSION_FILE_ENTRY, /// the version locator INI entry is not a valid directory URL
98 MISSING_USER_DIRECTORY, /// the user installation directory does not exist
99 INVALID_BOOTSTRAP_DATA /// some bootstrap data was invalid in unexpected ways
102 /** Evaluates the status of the installation and returns a diagnostic
103 message and error code corresponding to this status
105 static Status checkBootstrapStatus(OUString& _rDiagnosticMessage, FailureCode& _rErrCode);
107 public:
108 /// get the working directory of the process
109 static bool getProcessWorkingDir(OUString &rUrl);
111 public:
112 // singleton impl-class
113 class UNOTOOLS_DLLPRIVATE Impl;
114 static const Impl& data(); // the data related to the bootstrap.ini file
118 #endif
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */