Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / desktop / inc / app.hxx
blob01224c68ffeb9d715cb9f4e4d32d0523bd15aeee
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_DESKTOP_INC_APP_HXX
21 #define INCLUDED_DESKTOP_INC_APP_HXX
23 #include <boost/optional.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <sal/log.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/timer.hxx>
28 #include <unotools/bootstrap.hxx>
29 #include <unotools/resmgr.hxx>
30 #include <com/sun/star/frame/XDesktop2.hpp>
31 #include <com/sun/star/task/XStatusIndicator.hpp>
32 #include <com/sun/star/uno/Reference.h>
34 #include <memory>
35 #include <thread>
37 namespace com { namespace sun { namespace star { namespace uno {
38 class XComponentContext;
39 } } } }
41 namespace desktop
44 /*--------------------------------------------------------------------
45 Description: Application-class
46 --------------------------------------------------------------------*/
47 class CommandLineArgs;
48 class Lockfile;
49 struct ConvertData;
50 class Desktop : public Application
52 int doShutdown();
54 public:
55 enum BootstrapError
57 BE_OK,
58 BE_UNO_SERVICEMANAGER,
59 BE_UNO_SERVICE_CONFIG_MISSING,
60 BE_PATHINFO_MISSING,
61 BE_USERINSTALL_FAILED,
62 BE_LANGUAGE_MISSING,
63 BE_USERINSTALL_NOTENOUGHDISKSPACE,
64 BE_USERINSTALL_NOWRITEACCESS,
65 BE_OFFICECONFIG_BROKEN
67 enum BootstrapStatus
69 BS_OK,
70 BS_TERMINATE
73 Desktop();
74 virtual ~Desktop() override;
75 virtual int Main( ) override;
76 virtual void Init() override;
77 virtual void InitFinished() override;
78 virtual void DeInit() override;
79 virtual bool QueryExit() override;
80 virtual void Exception(ExceptionCategory nCategory) override;
81 virtual void OverrideSystemSettings( AllSettings& rSettings ) override;
82 virtual void AppEvent( const ApplicationEvent& rAppEvent ) override;
84 DECL_LINK( OpenClients_Impl, void*, void );
86 static void OpenClients();
87 static void OpenDefault();
88 static void CheckOpenCLCompute(const css::uno::Reference<css::frame::XDesktop2> &);
90 DECL_STATIC_LINK( Desktop, EnableAcceptors_Impl, void*, void);
92 static void HandleAppEvent( const ApplicationEvent& rAppEvent );
93 static CommandLineArgs& GetCommandLineArgs();
95 static void HandleBootstrapErrors(
96 BootstrapError nError, OUString const & aMessage );
97 void SetBootstrapError(
98 BootstrapError nError, OUString const & aMessage )
100 if ( m_aBootstrapError == BE_OK )
102 SAL_INFO("desktop.app", "SetBootstrapError: " << nError << " '" << aMessage << "'");
103 m_aBootstrapError = nError;
104 m_aBootstrapErrorMessage = aMessage;
108 void SetBootstrapStatus( BootstrapStatus nStatus )
110 m_aBootstrapStatus = nStatus;
112 BootstrapStatus GetBootstrapStatus() const
114 return m_aBootstrapStatus;
117 // first-start (ever) related methods
118 static bool CheckExtensionDependencies();
120 static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop* pDesktop = nullptr);
121 void SetSplashScreenText( const OUString& rText );
122 void SetSplashScreenProgress( sal_Int32 );
124 // Bootstrap methods
125 static void InitApplicationServiceManager();
126 // throws an exception upon failure
128 private:
129 void RegisterServices(
130 css::uno::Reference< css::uno::XComponentContext > const & context);
131 static void DeregisterServices();
133 public:
134 static void CreateTemporaryDirectory();
135 static void RemoveTemporaryDirectory();
137 private:
138 static bool InitializeConfiguration();
139 static void FlushConfiguration();
140 static bool InitializeQuickstartMode( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
142 static void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const OUString& aMsg );
144 // Create a error message depending on bootstrap failure code and an optional file url
145 static OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
146 const OUString& aFileURL );
148 css::uno::Reference<css::task::XStatusIndicator> m_rSplashScreen;
149 void OpenSplashScreen();
150 void CloseSplashScreen();
152 DECL_STATIC_LINK( Desktop, ImplInitFilterHdl, ::ConvertData&, bool );
153 DECL_STATIC_LINK( Desktop, AsyncInitFirstRun, Timer*, void );
154 /** checks if the office is run the first time
155 <p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the
156 respective flag in the configuration is reset.</p>
158 void CheckFirstRun( );
160 static void ShowBackingComponent(Desktop * progress);
162 // on-demand acceptors
163 static void createAcceptor(const OUString& aDescription);
164 static void destroyAcceptor(const OUString& aDescription);
166 bool m_bCleanedExtensionCache;
167 bool m_bServicesRegistered;
168 BootstrapError m_aBootstrapError;
169 OUString m_aBootstrapErrorMessage;
170 BootstrapStatus m_aBootstrapStatus;
172 std::unique_ptr<Lockfile> m_xLockfile;
173 Timer m_firstRunTimer;
174 std::thread m_aUpdateThread;
177 OUString GetURL_Impl(
178 const OUString& rName, boost::optional< OUString > const & cwdUrl );
180 OUString ReplaceStringHookProc(const OUString& rStr);
184 #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined LIBO_HEADLESS
185 bool fire_glxtest_process();
186 void reap_glxtest_process();
187 #endif
189 #endif // INCLUDED_DESKTOP_INC_APP_HXX
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */