xref: /trunk/main/unotools/inc/unotools/bootstrap.hxx (revision d9bf74e3)
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 
24 #include "unotools/unotoolsdllapi.h"
25 
26 #ifndef _UTL_BOOTSTRAP_HXX
27 #define _UTL_BOOTSTRAP_HXX
28 
29 namespace rtl
30 {
31     class OUString;
32 }
33 
34 namespace utl
35 {
36 //-----------------------------------------------------------------------------
37     /** provides configuration information needed for application startup.
38         <p>This class handles the startup information for the office application.
39            It encapsulates knowledge of how to retrieve such information and how
40            to diagnose failures to retrieve required data.
41         </p>
42     */
43     class UNOTOOLS_DLLPUBLIC Bootstrap
44     {
45     // the static interface
46     public: // some common information items
47 
48         /// retrieve the product key; defaults to executable name (without extension)
49         static rtl::OUString getProductKey();
50 
51         /// retrieve the product key; uses the given default, if not found
52         static rtl::OUString getProductKey(rtl::OUString const& _sDefault);
53 
54         /// retrieve the product source (MWS name)
55         static ::rtl::OUString getProductSource(rtl::OUString const& _sDefault);
56 
57         /// retrieve the BUILDID information item; uses the given default, if not found
58         static rtl::OUString getBuildIdData(rtl::OUString const& _sDefault);
59 
60         /// retrieve the SCS Revision information item
61         static rtl::OUString getRevisionInfo();
62 
63 		/// retrieve the ALLUSERS information item from setup.ini file; uses the given default, if not found
64 		static rtl::OUString getAllUsersValue(rtl::OUString const& _sDefault);
65 
66         /// reload cached data
67         static void reloadData();
68 
69 	public: // retrieve path information about the installation location
70         enum PathStatus
71         {
72             PATH_EXISTS,  // Success: Found a path to an existing file or directory
73             PATH_VALID,   // Found a valid path, but the file or directory does not exist
74             DATA_INVALID, // Retrieved a string for this path, that is not a valid file url or system path
75             DATA_MISSING, // Could not retrieve any data for this path
76             DATA_UNKNOWN  // No attempt to retrieve data for this path was made
77         };
78 
79         /// get a file URL to the common base installation [${insturl}]
80         static PathStatus locateBaseInstallation(rtl::OUString& _rURL);
81 
82         /// get a file URL to the user installation [${userurl}]
83         static PathStatus locateUserInstallation(rtl::OUString& _rURL);
84 
85         /// get a file URL to the shared data directory [default is ${insturl}/share]
86         static PathStatus locateSharedData(rtl::OUString& _rURL);
87 
88         /// get a file URL to the user data directory [default is ${userurl}/user]
89         static PathStatus locateUserData(rtl::OUString& _rURL);
90 
91     // the next two items are mainly supported for diagnostic purposes. both items may be unused
92         /// get a file URL to the bootstrap INI file used [e.g. ${insturl}/program/bootraprc]
93         static PathStatus locateBootstrapFile(rtl::OUString& _rURL);
94         /// get a file URL to the version locator INI file used [e.g. ${SYSUSERCONFIG}/sversion.ini]
95         static PathStatus locateVersionFile(rtl::OUString& _rURL);
96 
97     public: // evaluate the validity of the installation
98         /// high-level status of bootstrap success
99         enum Status
100         {
101             DATA_OK,              /// user-dir and share-dir do exist, product key found or can be defaulted to exe-name
102             MISSING_USER_INSTALL, /// ${userurl} does not exist; or version-file cannot be found or is invalid
103             INVALID_USER_INSTALL, /// can locate ${userurl}, but user-dir is missing
104             INVALID_BASE_INSTALL  /// other failure: e.g. cannot locate share-dir; bootstraprc missing or invalid; no product key
105         };
106 
107         /// error code for detailed diagnostics of bootstrap failures
108         enum FailureCode
109         {
110             NO_FAILURE,                   /// bootstrap was successful
111             MISSING_INSTALL_DIRECTORY,    /// the shared installation directory could not be located
112             MISSING_BOOTSTRAP_FILE,       /// the bootstrap INI file could not be found or read
113             MISSING_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI is missing a required entry
114             INVALID_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI contains invalid data
115             MISSING_VERSION_FILE,         /// the version locator INI file could not be found or read
116             MISSING_VERSION_FILE_ENTRY,   /// the version locator INI has no entry for this version
117             INVALID_VERSION_FILE_ENTRY,   /// the version locator INI entry is not a valid directory URL
118             MISSING_USER_DIRECTORY,       /// the user installation directory does not exist
119             INVALID_BOOTSTRAP_DATA        /// some bootstrap data was invalid in unexpected ways
120         };
121 
122         /// Evaluates the status of the installation and returns a diagnostic message corresponding to this status
123         static Status checkBootstrapStatus(rtl::OUString& _rDiagnosticMessage);
124 
125         /** Evaluates the status of the installation and returns a diagnostic
126             message and error code corresponding to this status
127         */
128         static Status checkBootstrapStatus(rtl::OUString& _rDiagnosticMessage, FailureCode& _rErrCode);
129 
130     public:
131         // singleton impl-class
132         class Impl;
133         static Impl const& data(); // the data related to the bootstrap.ini file
134     };
135 //-----------------------------------------------------------------------------
136 } // namespace utl
137 
138 #endif // _UTL_BOOTSTRAP_HXX
139