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 .
23 #include <sal/log.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/timer.hxx>
26 #include <unotools/bootstrap.hxx>
27 #include <com/sun/star/frame/XDesktop2.hpp>
28 #include <com/sun/star/task/XStatusIndicator.hpp>
29 #include <com/sun/star/uno/Reference.h>
34 namespace com::sun::star::uno
{ class XComponentContext
; }
39 /*--------------------------------------------------------------------
40 Description: Application-class
41 --------------------------------------------------------------------*/
42 class CommandLineArgs
;
45 class Desktop final
: public Application
53 BE_UNO_SERVICEMANAGER
,
54 BE_UNO_SERVICE_CONFIG_MISSING
,
56 BE_USERINSTALL_FAILED
,
58 BE_USERINSTALL_NOTENOUGHDISKSPACE
,
59 BE_USERINSTALL_NOWRITEACCESS
,
60 BE_OFFICECONFIG_BROKEN
69 virtual ~Desktop() override
;
70 virtual int Main( ) override
;
71 virtual void Init() override
;
72 virtual void InitFinished() override
;
73 virtual void DeInit() override
;
74 virtual bool QueryExit() override
;
75 virtual void Shutdown() override
;
76 virtual void Exception(ExceptionCategory nCategory
) override
;
77 virtual void OverrideSystemSettings( AllSettings
& rSettings
) override
;
78 virtual void AppEvent( const ApplicationEvent
& rAppEvent
) override
;
80 DECL_LINK( OpenClients_Impl
, void*, void );
82 static void OpenClients();
83 static void OpenDefault();
84 static void CheckOpenCLCompute(const css::uno::Reference
<css::frame::XDesktop2
> &);
86 DECL_STATIC_LINK( Desktop
, EnableAcceptors_Impl
, void*, void);
88 static void HandleAppEvent( const ApplicationEvent
& rAppEvent
);
89 static CommandLineArgs
& GetCommandLineArgs();
91 static void HandleBootstrapErrors(
92 BootstrapError nError
, OUString
const & aMessage
);
93 void SetBootstrapError(
94 BootstrapError nError
, OUString
const & aMessage
)
96 if ( m_aBootstrapError
== BE_OK
)
98 SAL_INFO("desktop.app", "SetBootstrapError: " << nError
<< " '" << aMessage
<< "'");
99 m_aBootstrapError
= nError
;
100 m_aBootstrapErrorMessage
= aMessage
;
104 void SetBootstrapStatus( BootstrapStatus nStatus
)
106 m_aBootstrapStatus
= nStatus
;
108 BootstrapStatus
GetBootstrapStatus() const
110 return m_aBootstrapStatus
;
113 // first-start (ever) related methods
114 static bool CheckExtensionDependencies();
116 static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache
, Desktop
* pDesktop
= nullptr);
117 void SetSplashScreenText( const OUString
& rText
);
118 void SetSplashScreenProgress( sal_Int32
);
121 static void InitApplicationServiceManager();
122 // throws an exception upon failure
125 void RegisterServices(
126 css::uno::Reference
< css::uno::XComponentContext
> const & context
);
127 static void DeregisterServices();
130 static void CreateTemporaryDirectory();
131 static void RemoveTemporaryDirectory();
134 static bool InitializeConfiguration();
135 static void FlushConfiguration();
136 static bool InitializeQuickstartMode( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
138 static void HandleBootstrapPathErrors( ::utl::Bootstrap::Status
, const OUString
& aMsg
);
140 // Create an error message depending on bootstrap failure code and an optional file url
141 static OUString
CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode
,
142 const OUString
& aFileURL
);
144 css::uno::Reference
<css::task::XStatusIndicator
> m_rSplashScreen
;
145 void OpenSplashScreen();
146 void CloseSplashScreen();
148 DECL_STATIC_LINK( Desktop
, ImplInitFilterHdl
, ::ConvertData
&, bool );
149 DECL_STATIC_LINK( Desktop
, AsyncInitFirstRun
, Timer
*, void );
150 /** checks if the office is run the first time
151 <p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the
152 respective flag in the configuration is reset.</p>
154 void CheckFirstRun( );
156 static void ShowBackingComponent(Desktop
* progress
);
158 // on-demand acceptors
159 static void createAcceptor(const OUString
& aDescription
);
160 static void destroyAcceptor(const OUString
& aDescription
);
162 bool m_bCleanedExtensionCache
;
163 bool m_bServicesRegistered
;
164 BootstrapError m_aBootstrapError
;
165 OUString m_aBootstrapErrorMessage
;
166 BootstrapStatus m_aBootstrapStatus
;
168 std::unique_ptr
<Lockfile
> m_xLockfile
;
169 Timer m_firstRunTimer
;
170 std::thread m_aUpdateThread
;
173 OUString
GetURL_Impl(
174 const OUString
& rName
, std::optional
< OUString
> const & cwdUrl
);
176 OUString
ReplaceStringHookProc(const OUString
& rStr
);
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */