Line data Source code
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 _DESKTOP_APP_HXX_
21 : #define _DESKTOP_APP_HXX_
22 :
23 : // stl includes first
24 : #include <map>
25 : #include <boost/scoped_ptr.hpp>
26 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 : #include <vcl/svapp.hxx>
28 : #include <vcl/timer.hxx>
29 : #include <tools/resmgr.hxx>
30 : #include <unotools/bootstrap.hxx>
31 : #include <com/sun/star/lang/XInitialization.hpp>
32 : #include <com/sun/star/task/XStatusIndicator.hpp>
33 : #include <com/sun/star/uno/Reference.h>
34 : #include <osl/mutex.hxx>
35 :
36 : namespace com { namespace sun { namespace star { namespace uno {
37 : class XComponentContext;
38 : } } } }
39 :
40 : namespace desktop
41 : {
42 :
43 : /*--------------------------------------------------------------------
44 : Description: Application-class
45 : --------------------------------------------------------------------*/
46 : class CommandLineArgs;
47 : class Lockfile;
48 166 : class AcceptorMap : public std::map< OUString, css::uno::Reference<css::lang::XInitialization> > {};
49 : struct ConvertData;
50 : class Desktop : public Application
51 : {
52 : friend class UserInstall;
53 :
54 : int doShutdown();
55 :
56 : public:
57 : enum BootstrapError
58 : {
59 : BE_OK,
60 : BE_UNO_SERVICEMANAGER,
61 : BE_UNO_SERVICE_CONFIG_MISSING,
62 : BE_PATHINFO_MISSING,
63 : BE_USERINSTALL_FAILED,
64 : BE_LANGUAGE_MISSING,
65 : BE_USERINSTALL_NOTENOUGHDISKSPACE,
66 : BE_USERINSTALL_NOWRITEACCESS,
67 : BE_OFFICECONFIG_BROKEN
68 : };
69 : enum BootstrapStatus
70 : {
71 : BS_OK,
72 : BS_TERMINATE
73 : };
74 :
75 : Desktop();
76 : ~Desktop();
77 : virtual int Main( );
78 : virtual void Init();
79 : virtual void InitFinished();
80 : virtual void DeInit();
81 : virtual sal_Bool QueryExit();
82 : virtual sal_uInt16 Exception(sal_uInt16 nError);
83 : virtual void SystemSettingsChanging( AllSettings& rSettings, Window* pFrame );
84 : virtual void AppEvent( const ApplicationEvent& rAppEvent );
85 :
86 : DECL_LINK( OpenClients_Impl, void* );
87 :
88 : static void OpenClients();
89 : static void OpenDefault();
90 :
91 : DECL_LINK( EnableAcceptors_Impl, void*);
92 :
93 : static void HandleAppEvent( const ApplicationEvent& rAppEvent );
94 : static ResMgr* GetDesktopResManager();
95 : static CommandLineArgs& GetCommandLineArgs();
96 :
97 : void HandleBootstrapErrors(
98 : BootstrapError nError, OUString const & aMessage );
99 0 : void SetBootstrapError(
100 : BootstrapError nError, OUString const & aMessage )
101 : {
102 0 : if ( m_aBootstrapError == BE_OK )
103 : {
104 0 : m_aBootstrapError = nError;
105 0 : m_aBootstrapErrorMessage = aMessage;
106 : }
107 0 : }
108 :
109 83 : void SetBootstrapStatus( BootstrapStatus nStatus )
110 : {
111 83 : m_aBootstrapStatus = nStatus;
112 83 : }
113 83 : BootstrapStatus GetBootstrapStatus() const
114 : {
115 83 : return m_aBootstrapStatus;
116 : }
117 :
118 : static sal_Bool isCrashReporterEnabled();
119 :
120 : // first-start (ever) related methods
121 : static sal_Bool CheckExtensionDependencies();
122 :
123 : static void DoRestartActionsIfNecessary( sal_Bool bQuickStart );
124 : static void SetRestartState();
125 :
126 : void SynchronizeExtensionRepositories();
127 : void SetSplashScreenText( const OUString& rText );
128 : void SetSplashScreenProgress( sal_Int32 );
129 :
130 : // Bootstrap methods
131 : static void InitApplicationServiceManager();
132 : // throws an exception upon failure
133 :
134 : private:
135 : void RegisterServices(
136 : css::uno::Reference<
137 : css::uno::XComponentContext > const & context);
138 : void DeregisterServices();
139 :
140 : void CreateTemporaryDirectory();
141 : void RemoveTemporaryDirectory();
142 :
143 : sal_Bool InitializeInstallation( const OUString& rAppFilename );
144 : bool InitializeConfiguration();
145 : void FlushConfiguration();
146 : static sal_Bool shouldLaunchQuickstart();
147 : sal_Bool InitializeQuickstartMode( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
148 :
149 : void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const OUString& aMsg );
150 : void StartSetup( const OUString& aParameters );
151 :
152 : // Create a error message depending on bootstrap failure code and an optional file url
153 : OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
154 : const OUString& aFileURL );
155 :
156 : static void PreloadModuleData( const CommandLineArgs& );
157 : static void PreloadConfigurationData();
158 :
159 : css::uno::Reference<css::task::XStatusIndicator> m_rSplashScreen;
160 : void OpenSplashScreen();
161 : void CloseSplashScreen();
162 :
163 : void EnableOleAutomation();
164 : DECL_LINK( ImplInitFilterHdl, ConvertData* );
165 : DECL_LINK( AsyncInitFirstRun, void* );
166 : /** checks if the office is run the first time
167 : <p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the
168 : respective flag in the configuration is reset.</p>
169 : */
170 : void CheckFirstRun( );
171 :
172 : /// does initializations which are necessary for the first run of the office
173 : void DoFirstRunInitializations();
174 :
175 : static void ShowBackingComponent(Desktop * progress);
176 :
177 : static sal_Bool SaveTasks();
178 :
179 : static void retrieveCrashReporterState();
180 : static sal_Bool isUIOnSessionShutdownAllowed();
181 :
182 : // on-demand acceptors
183 : static void createAcceptor(const OUString& aDescription);
184 : static void enableAcceptors();
185 : static void destroyAcceptor(const OUString& aDescription);
186 :
187 : bool m_bCleanedExtensionCache;
188 : bool m_bServicesRegistered;
189 : BootstrapError m_aBootstrapError;
190 : OUString m_aBootstrapErrorMessage;
191 : BootstrapStatus m_aBootstrapStatus;
192 :
193 : boost::scoped_ptr<Lockfile> m_xLockfile;
194 : Timer m_firstRunTimer;
195 :
196 : static ResMgr* pResMgr;
197 : };
198 :
199 : }
200 :
201 : #endif // _DESKTOP_APP_HXX_
202 :
203 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|