1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #include "unotools/unotoolsdllapi.h" 24 25 #ifndef _UTL_BOOTSTRAP_HXX 26 #define _UTL_BOOTSTRAP_HXX 27 28 namespace rtl 29 { 30 class OUString; 31 } 32 33 namespace utl 34 { 35 //----------------------------------------------------------------------------- 36 /** provides configuration information needed for application startup. 37 <p>This class handles the startup information for the office application. 38 It encapsulates knowledge of how to retriev such information and how 39 to diagnose failures to retriev required data. 40 </p> 41 */ 42 class UNOTOOLS_DLLPUBLIC Bootstrap 43 { 44 // the static interface 45 public: // some common information items 46 47 /// retrieve the product key; defaults to executable name (without extension) 48 static rtl::OUString getProductKey(); 49 50 /// retrieve the product key; uses the given default, if not found 51 static rtl::OUString getProductKey(rtl::OUString const& _sDefault); 52 53 /// retrieve the product source (MWS name) 54 static ::rtl::OUString getProductSource(rtl::OUString const& _sDefault); 55 56 /// retrieve the BUILDID information item; uses the given default, if not found 57 static rtl::OUString getBuildIdData(rtl::OUString const& _sDefault); 58 59 /// retrieve the SCS Revision information item 60 static rtl::OUString getRevisionInfo(); 61 62 /// retrieve the ALLUSERS information item from setup.ini file; uses the given default, if not found 63 static rtl::OUString getAllUsersValue(rtl::OUString const& _sDefault); 64 65 /// reload cached data 66 static void reloadData(); 67 68 public: // retrieve path information about the installat�on location 69 enum PathStatus 70 { 71 PATH_EXISTS, // Success: Found a path to an existing file or directory 72 PATH_VALID, // Found a valid path, but the file or directory does not exist 73 DATA_INVALID, // Retrieved a string for this path, that is not a valid file url or system path 74 DATA_MISSING, // Could not retrieve any data for this path 75 DATA_UNKNOWN // No attempt to retrieve data for this path was made 76 }; 77 78 /// get a file URL to the common base installation [${insturl}] 79 static PathStatus locateBaseInstallation(rtl::OUString& _rURL); 80 81 /// get a file URL to the user installation [${userurl}] 82 static PathStatus locateUserInstallation(rtl::OUString& _rURL); 83 84 /// get a file URL to the shared data directory [default is ${insturl}/share] 85 static PathStatus locateSharedData(rtl::OUString& _rURL); 86 87 /// get a file URL to the user data directory [default is ${userurl}/user] 88 static PathStatus locateUserData(rtl::OUString& _rURL); 89 90 // the next two items are mainly supported for diagnostic purposes. both items may be unused 91 /// get a file URL to the bootstrap INI file used [e.g. ${insturl}/program/bootraprc] 92 static PathStatus locateBootstrapFile(rtl::OUString& _rURL); 93 /// get a file URL to the version locator INI file used [e.g. ${SYSUSERCONFIG}/sversion.ini] 94 static PathStatus locateVersionFile(rtl::OUString& _rURL); 95 96 public: // evaluate the validity of the installation 97 /// high-level status of bootstrap success 98 enum Status 99 { 100 DATA_OK, /// user-dir and share-dir do exist, product key found or can be defaulted to exe-name 101 MISSING_USER_INSTALL, /// ${userurl} does not exist; or version-file cannot be found or is invalid 102 INVALID_USER_INSTALL, /// can locate ${userurl}, but user-dir is missing 103 INVALID_BASE_INSTALL /// other failure: e.g. cannot locate share-dir; bootstraprc missing or invalid; no product key 104 }; 105 106 /// error code for detailed diagnostics of bootstrap failures 107 enum FailureCode 108 { 109 NO_FAILURE, /// bootstrap was successful 110 MISSING_INSTALL_DIRECTORY, /// the shared installation directory could not be located 111 MISSING_BOOTSTRAP_FILE, /// the bootstrap INI file could not be found or read 112 MISSING_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI is missing a required entry 113 INVALID_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI contains invalid data 114 MISSING_VERSION_FILE, /// the version locator INI file could not be found or read 115 MISSING_VERSION_FILE_ENTRY, /// the version locator INI has no entry for this version 116 INVALID_VERSION_FILE_ENTRY, /// the version locator INI entry is not a valid directory URL 117 MISSING_USER_DIRECTORY, /// the user installation directory does not exist 118 INVALID_BOOTSTRAP_DATA /// some bootstrap data was invalid in unexpected ways 119 }; 120 121 /// Evaluates the status of the installation and returns a diagnostic message corresponding to this status 122 static Status checkBootstrapStatus(rtl::OUString& _rDiagnosticMessage); 123 124 /** Evaluates the status of the installation and returns a diagnostic 125 message and error code corresponding to this status 126 */ 127 static Status checkBootstrapStatus(rtl::OUString& _rDiagnosticMessage, FailureCode& _rErrCode); 128 129 public: 130 // singleton impl-class 131 class Impl; 132 static Impl const& data(); // the data related to the bootstrap.ini file 133 }; 134 //----------------------------------------------------------------------------- 135 } // namespace utl 136 137 #endif // _UTL_BOOTSTRAP_HXX 138