Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _DESKTOP_APP_HXX_
30 : : #define _DESKTOP_APP_HXX_
31 : :
32 : : // stl includes first
33 : : #include <map>
34 : : #include <memory>
35 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 : : #include <vcl/svapp.hxx>
37 : : #include <vcl/timer.hxx>
38 : : #include <tools/resmgr.hxx>
39 : : #include <unotools/bootstrap.hxx>
40 : : #include <com/sun/star/lang/XInitialization.hpp>
41 : : #include <com/sun/star/task/XStatusIndicator.hpp>
42 : : #include <com/sun/star/uno/Reference.h>
43 : : #include <osl/mutex.hxx>
44 : :
45 : : using namespace com::sun::star::task;
46 : : using namespace com::sun::star::uno;
47 : : using namespace com::sun::star::lang;
48 : :
49 : : namespace desktop
50 : : {
51 : :
52 : : /*--------------------------------------------------------------------
53 : : Description: Application-class
54 : : --------------------------------------------------------------------*/
55 : : class CommandLineArgs;
56 : : class Lockfile;
57 : 316 : class AcceptorMap : public std::map< rtl::OUString, Reference<XInitialization> > {};
58 : : struct ConvertData;
59 : : class Desktop : public Application
60 : : {
61 : : friend class UserInstall;
62 : :
63 : : int doShutdown();
64 : :
65 : : public:
66 : : enum BootstrapError
67 : : {
68 : : BE_OK,
69 : : BE_UNO_SERVICEMANAGER,
70 : : BE_UNO_SERVICE_CONFIG_MISSING,
71 : : BE_PATHINFO_MISSING,
72 : : BE_USERINSTALL_FAILED,
73 : : BE_LANGUAGE_MISSING,
74 : : BE_USERINSTALL_NOTENOUGHDISKSPACE,
75 : : BE_USERINSTALL_NOWRITEACCESS,
76 : : BE_OFFICECONFIG_BROKEN
77 : : };
78 : : enum BootstrapStatus
79 : : {
80 : : BS_OK,
81 : : BS_TERMINATE
82 : : };
83 : :
84 : : Desktop();
85 : : ~Desktop();
86 : : virtual int Main( );
87 : : virtual void Init();
88 : : virtual void InitFinished();
89 : : virtual void DeInit();
90 : : virtual sal_Bool QueryExit();
91 : : virtual sal_uInt16 Exception(sal_uInt16 nError);
92 : : virtual void SystemSettingsChanging( AllSettings& rSettings, Window* pFrame );
93 : : virtual void AppEvent( const ApplicationEvent& rAppEvent );
94 : :
95 : : DECL_LINK( OpenClients_Impl, void* );
96 : :
97 : : static void OpenClients();
98 : : static void OpenDefault();
99 : :
100 : : DECL_LINK( EnableAcceptors_Impl, void*);
101 : :
102 : : static void HandleAppEvent( const ApplicationEvent& rAppEvent );
103 : : static ResMgr* GetDesktopResManager();
104 : : static CommandLineArgs& GetCommandLineArgs();
105 : :
106 : : void HandleBootstrapErrors( BootstrapError );
107 : 0 : void SetBootstrapError( BootstrapError nError )
108 : : {
109 [ # # ]: 0 : if ( m_aBootstrapError == BE_OK )
110 : 0 : m_aBootstrapError = nError;
111 : 0 : }
112 : 474 : BootstrapError GetBootstrapError() const
113 : : {
114 : 474 : return m_aBootstrapError;
115 : : }
116 : :
117 : 158 : void SetBootstrapStatus( BootstrapStatus nStatus )
118 : : {
119 : 158 : m_aBootstrapStatus = nStatus;
120 : 158 : }
121 : 158 : BootstrapStatus GetBootstrapStatus() const
122 : : {
123 : 158 : return m_aBootstrapStatus;
124 : : }
125 : :
126 : : static sal_Bool isCrashReporterEnabled();
127 : :
128 : : // first-start (ever) related methods
129 : : static sal_Bool CheckExtensionDependencies();
130 : :
131 : : static void DoRestartActionsIfNecessary( sal_Bool bQuickStart );
132 : : static void SetRestartState();
133 : :
134 : : void SynchronizeExtensionRepositories();
135 : : void SetSplashScreenText( const ::rtl::OUString& rText );
136 : : void SetSplashScreenProgress( sal_Int32 );
137 : :
138 : : static void ensureProcessServiceFactory();
139 : :
140 : : private:
141 : : // Bootstrap methods
142 : : static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager();
143 : : // returns a non-null reference or throws an exception
144 : :
145 : : void RegisterServices();
146 : : void DeregisterServices();
147 : :
148 : : void DestroyApplicationServiceManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr );
149 : :
150 : : void CreateTemporaryDirectory();
151 : : void RemoveTemporaryDirectory();
152 : :
153 : : sal_Bool InitializeInstallation( const rtl::OUString& rAppFilename );
154 : : bool InitializeConfiguration();
155 : : void FlushConfiguration();
156 : : static sal_Bool shouldLaunchQuickstart();
157 : : sal_Bool InitializeQuickstartMode( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr );
158 : :
159 : : void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg );
160 : : void StartSetup( const ::rtl::OUString& aParameters );
161 : :
162 : : // Get a resource message string securely e.g. if resource cannot be retrieved return aFaultBackMsg
163 : : ::rtl::OUString GetMsgString( sal_uInt16 nId, const ::rtl::OUString& aFaultBackMsg );
164 : :
165 : : // Create a error message depending on bootstrap failure code and an optional file url
166 : : ::rtl::OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
167 : : const ::rtl::OUString& aFileURL );
168 : :
169 : : static void PreloadModuleData( const CommandLineArgs& );
170 : : static void PreloadConfigurationData();
171 : :
172 : : Reference<XStatusIndicator> m_rSplashScreen;
173 : : void OpenSplashScreen();
174 : : void CloseSplashScreen();
175 : :
176 : : void EnableOleAutomation();
177 : : DECL_LINK( ImplInitFilterHdl, ConvertData* );
178 : : DECL_LINK( AsyncInitFirstRun, void* );
179 : : /** checks if the office is run the first time
180 : : <p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the
181 : : respective flag in the configuration is reset.</p>
182 : : */
183 : : void CheckFirstRun( );
184 : :
185 : : /// does initializations which are necessary for the first run of the office
186 : : void DoFirstRunInitializations();
187 : :
188 : : static void ShowBackingComponent(Desktop * progress);
189 : :
190 : : static sal_Bool SaveTasks();
191 : :
192 : : static void retrieveCrashReporterState();
193 : : static sal_Bool isUIOnSessionShutdownAllowed();
194 : :
195 : : // on-demand acceptors
196 : : static void createAcceptor(const rtl::OUString& aDescription);
197 : : static void enableAcceptors();
198 : : static void destroyAcceptor(const rtl::OUString& aDescription);
199 : :
200 : : sal_Bool m_bMinimized;
201 : : sal_Bool m_bInvisible;
202 : : bool m_bServicesRegistered;
203 : : sal_uInt16 m_nAppEvents;
204 : : BootstrapError m_aBootstrapError;
205 : : BootstrapStatus m_aBootstrapStatus;
206 : :
207 : : std::auto_ptr< Lockfile > m_pLockfile;
208 : : Timer m_firstRunTimer;
209 : :
210 : : static ResMgr* pResMgr;
211 : : static sal_Bool bSuppressOpenDefault;
212 : : };
213 : :
214 : : }
215 : :
216 : : #endif // _DESKTOP_APP_HXX_
217 : :
218 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|