LibreOffice Module desktop (master)  1
app.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_DESKTOP_INC_APP_HXX
21 #define INCLUDED_DESKTOP_INC_APP_HXX
22 
23 #include <optional>
24 #include <sal/log.hxx>
25 #include <vcl/svapp.hxx>
26 #include <vcl/timer.hxx>
27 #include <unotools/bootstrap.hxx>
28 #include <com/sun/star/frame/XDesktop2.hpp>
29 #include <com/sun/star/task/XStatusIndicator.hpp>
30 #include <com/sun/star/uno/Reference.h>
31 
32 #include <memory>
33 #include <thread>
34 
35 namespace com { namespace sun { namespace star { namespace uno {
36  class XComponentContext;
37 } } } }
38 
39 namespace desktop
40 {
41 
42 /*--------------------------------------------------------------------
43  Description: Application-class
44  --------------------------------------------------------------------*/
45 class CommandLineArgs;
46 class Lockfile;
47 struct ConvertData;
48 class Desktop final : public Application
49 {
50  int doShutdown();
51 
52  public:
54  {
64  };
66  {
69  };
70 
71  Desktop();
72  virtual ~Desktop() override;
73  virtual int Main( ) override;
74  virtual void Init() override;
75  virtual void InitFinished() override;
76  virtual void DeInit() override;
77  virtual bool QueryExit() override;
78  virtual void Shutdown() override;
79  virtual void Exception(ExceptionCategory nCategory) override;
80  virtual void OverrideSystemSettings( AllSettings& rSettings ) override;
81  virtual void AppEvent( const ApplicationEvent& rAppEvent ) override;
82 
83  DECL_LINK( OpenClients_Impl, void*, void );
84 
85  static void OpenClients();
86  static void OpenDefault();
87  static void CheckOpenCLCompute(const css::uno::Reference<css::frame::XDesktop2> &);
88 
89  DECL_STATIC_LINK( Desktop, EnableAcceptors_Impl, void*, void);
90 
91  static void HandleAppEvent( const ApplicationEvent& rAppEvent );
93 
94  static void HandleBootstrapErrors(
95  BootstrapError nError, OUString const & aMessage );
97  BootstrapError nError, OUString const & aMessage )
98  {
99  if ( m_aBootstrapError == BE_OK )
100  {
101  SAL_INFO("desktop.app", "SetBootstrapError: " << nError << " '" << aMessage << "'");
102  m_aBootstrapError = nError;
103  m_aBootstrapErrorMessage = aMessage;
104  }
105  }
106 
108  {
109  m_aBootstrapStatus = nStatus;
110  }
112  {
113  return m_aBootstrapStatus;
114  }
115 
116  // first-start (ever) related methods
117  static bool CheckExtensionDependencies();
118 
119  static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop* pDesktop = nullptr);
120  void SetSplashScreenText( const OUString& rText );
121  void SetSplashScreenProgress( sal_Int32 );
122 
123  // Bootstrap methods
124  static void InitApplicationServiceManager();
125  // throws an exception upon failure
126 
127  private:
128  void RegisterServices(
129  css::uno::Reference< css::uno::XComponentContext > const & context);
130  static void DeregisterServices();
131 
132  public:
133  static void CreateTemporaryDirectory();
134  static void RemoveTemporaryDirectory();
135 
136  private:
137  static bool InitializeConfiguration();
138  static void FlushConfiguration();
139  static bool InitializeQuickstartMode( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
140 
141  static void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const OUString& aMsg );
142 
143  // Create an error message depending on bootstrap failure code and an optional file url
144  static OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
145  const OUString& aFileURL );
146 
147  css::uno::Reference<css::task::XStatusIndicator> m_rSplashScreen;
148  void OpenSplashScreen();
149  void CloseSplashScreen();
150 
151  DECL_STATIC_LINK( Desktop, ImplInitFilterHdl, ::ConvertData&, bool );
152  DECL_STATIC_LINK( Desktop, AsyncInitFirstRun, Timer*, void );
157  void CheckFirstRun( );
158 
159  static void ShowBackingComponent(Desktop * progress);
160 
161  // on-demand acceptors
162  static void createAcceptor(const OUString& aDescription);
163  static void destroyAcceptor(const OUString& aDescription);
164 
170 
171  std::unique_ptr<Lockfile> m_xLockfile;
173  std::thread m_aUpdateThread;
174 };
175 
176 OUString GetURL_Impl(
177  const OUString& rName, std::optional< OUString > const & cwdUrl );
178 
179 OUString ReplaceStringHookProc(const OUString& rStr);
180 
181 }
182 
183 #endif // INCLUDED_DESKTOP_INC_APP_HXX
184 
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void destroyAcceptor(const OUString &aDescription)
Definition: appinit.cxx:200
css::uno::Reference< css::task::XStatusIndicator > m_rSplashScreen
Definition: app.hxx:147
static bool InitializeConfiguration()
Definition: app.cxx:1743
void OpenSplashScreen()
Definition: app.cxx:2402
virtual void AppEvent(const ApplicationEvent &rAppEvent) override
Definition: app.cxx:1198
static void HandleBootstrapPathErrors(::utl::Bootstrap::Status, const OUString &aMsg)
Definition: app.cxx:617
void CheckFirstRun()
checks if the office is run the first time
Definition: app.cxx:2543
static void CreateTemporaryDirectory()
Definition: appinit.cxx:227
DECL_STATIC_LINK(Desktop, EnableAcceptors_Impl, void *, void)
virtual void DeInit() override
Definition: app.cxx:541
OUString ReplaceStringHookProc(const OUString &rStr)
Definition: app.cxx:393
std::unique_ptr< Lockfile > m_xLockfile
Definition: app.hxx:171
OUString GetURL_Impl(const OUString &rName, std::optional< OUString > const &cwdUrl)
Definition: app.cxx:2211
void SetBootstrapStatus(BootstrapStatus nStatus)
Definition: app.hxx:107
static OUString CreateErrorMsgString(utl::Bootstrap::FailureCode nFailureCode, const OUString &aFileURL)
Definition: app.cxx:643
int doShutdown()
Definition: app.cxx:1641
Definition: app.cxx:161
void SetSplashScreenProgress(sal_Int32)
Definition: app.cxx:2454
BootstrapError m_aBootstrapError
Definition: app.hxx:167
static void ShowBackingComponent(Desktop *progress)
Definition: app.cxx:2494
virtual void OverrideSystemSettings(AllSettings &rSettings) override
Definition: app.cxx:1852
static void FlushConfiguration()
Definition: app.cxx:1809
BootstrapStatus m_aBootstrapStatus
Definition: app.hxx:169
static void InitApplicationServiceManager()
Definition: appinit.cxx:65
ExceptionCategory
virtual ~Desktop() override
Definition: app.cxx:433
virtual void Init() override
Definition: app.cxx:437
static void DeregisterServices()
Definition: appinit.cxx:221
void RegisterServices(css::uno::Reference< css::uno::XComponentContext > const &context)
Definition: appinit.cxx:88
Timer m_firstRunTimer
Definition: app.hxx:172
static void RemoveTemporaryDirectory()
Definition: appinit.cxx:262
static void HandleBootstrapErrors(BootstrapError nError, OUString const &aMessage)
Definition: app.cxx:734
void SetBootstrapError(BootstrapError nError, OUString const &aMessage)
Definition: app.hxx:96
bool m_bCleanedExtensionCache
Definition: app.hxx:165
static CommandLineArgs & GetCommandLineArgs()
Definition: app.cxx:388
void SetSplashScreenText(const OUString &rText)
Definition: app.cxx:2462
static void OpenDefault()
Definition: app.cxx:2154
static void createAcceptor(const OUString &aDescription)
Definition: appinit.cxx:131
virtual void Shutdown() override
Definition: app.cxx:610
OUString m_aBootstrapErrorMessage
Definition: app.hxx:168
bool m_bServicesRegistered
Definition: app.hxx:166
std::thread m_aUpdateThread
Definition: app.hxx:173
static void HandleAppEvent(const ApplicationEvent &rAppEvent)
Definition: app.cxx:2260
static void CheckOpenCLCompute(const css::uno::Reference< css::frame::XDesktop2 > &)
static void SynchronizeExtensionRepositories(bool bCleanedExtensionCache, Desktop *pDesktop=nullptr)
#define SAL_INFO(area, stream)
virtual void InitFinished() override
Definition: app.cxx:536
static bool InitializeQuickstartMode(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: app.cxx:1817
DECL_LINK(OpenClients_Impl, void *, void)
virtual void Exception(ExceptionCategory nCategory) override
Definition: app.cxx:1123
static void OpenClients()
Definition: app.cxx:1941
virtual int Main() override
Definition: app.cxx:1223
virtual bool QueryExit() override
Definition: app.cxx:568
void CloseSplashScreen()
Definition: app.cxx:2470
static bool CheckExtensionDependencies()
BootstrapStatus GetBootstrapStatus() const
Definition: app.hxx:111